How to Run Background Tasks in Your Expo App

DavidDavid November 8, 2026 7 min read
A smartphone lying face down on a dark wooden nightstand at night, plugged into a charging cable, with a faint glow around its edges and a dim bedroom behind it
Original image, App Store Launch Club

How to run background tasks in your Expo app, in short

Install expo-background-task and expo-task-manager, write your task with TaskManager.defineTask in a file that loads when the app starts, and register it once with BackgroundTask.registerTaskAsync. The task function does its work and returns BackgroundTaskResult.Success or BackgroundTaskResult.Failed. Under the hood, iOS uses BGTaskScheduler and Android uses WorkManager.

This is the right tool for work that can wait: syncing queued changes to your server, prefetching content so the app opens fresh, or checking for an update. It is the wrong tool for anything that has to happen at a specific time. A background task may run hours after you hoped it would, and on iOS it may not run at all if the user force quit the app.

expo-background-task at a glance (SDK 58)

QuestionAnswer
Installnpx expo install expo-background-task expo-task-manager
PlatformsAndroid, iOS, tvOS
Default intervalOnce every 12 hours
Lowest interval you can ask for15 minutes
Exact timing?No, the system picks the time
iOS simulator?No, physical device only
Testing in Expo Go?No, use a development build
Old module to avoidexpo-background-fetch, which is deprecated

Step 1: Install the module and make a development build

Run npx expo install expo-background-task expo-task-manager. On SDK 58 that gives you the 58.0.x line of expo-background-task. Your code imports from both packages, so install both directly instead of leaning on one to pull in the other.

iOS needs two Info.plist entries: the processing value in UIBackgroundModes, and the identifier com.expo.modules.backgroundtask.processing in BGTaskSchedulerPermittedIdentifiers. If you use prebuild (Continuous Native Generation), both are applied for you. You only add them by hand if you maintain your own ios folder.

Those entries live in the native project, so you need a fresh [development build](/blog/expo-go-vs-development-build) after installing. An [over the air update](/blog/how-to-push-app-updates-without-app-store-review) will not add them. The same applies to production: this feature ships in a real [EAS build](/blog/eas-build-guide-for-expo-apps) and a store update.

Step 2: Define the task outside your components

TaskManager.defineTask has to run at the top level of your JavaScript bundle, not inside a React component. When the system launches your app in the background, no components are mounted. If the definition lives in a screen or a useEffect, it does not exist at the moment the system needs it.

In an Expo Router project, put it in its own file, such as tasks.ts, and import that file at the top of app/_layout.tsx. That way the task is defined before any navigation runs. Inside the function, wrap your work in try and catch, return BackgroundTaskResult.Failed from the catch, and return BackgroundTaskResult.Success at the end.

Because nothing is mounted, the task cannot read hooks, context or component state. Everything it needs has to come from storage or the network. Keep the logic in plain functions that a screen can also call, so the same sync runs when the user opens the app and when the system wakes it.

Step 3: Register it with a realistic interval

Call BackgroundTask.registerTaskAsync with the task name and an optional object holding minimumInterval, in minutes. Unlike defineTask, this can happen inside a component. Registered tasks are saved in persistent storage and restored when the app initializes, so check TaskManager.isTaskRegisteredAsync first and only register if it returns false. If the feature is optional, call unregisterTaskAsync when the user turns it off.

Treat minimumInterval as "no sooner than", because that is all it promises. Leave it out and you get 12 hours. The lowest value is 15 minutes. On Android the task runs some time after the interval passes, once its conditions are met. On iOS the system weighs battery level, network and how the person uses their phone, and short intervals are often ignored in favor of windows such as overnight.

What actually controls when your task runs

FactoriOSAndroid
SchedulerBGTaskSchedulerWorkManager
Your minimumIntervalA hint, short values are often ignoredA floor of at least 15 minutes
Battery and networkRequired, or the task does not runRequired, or the task does not run
User swipes the app awayFully terminated, tasks stop until reopenedUsually not a full stop, varies by device maker
Device rebootTasks resumeTasks resume

Two details that catch people out. First, a network connection is a condition, so this is not a way to do work while offline. Second, you can define several JavaScript tasks, but they all run through one single worker, and the last one you register sets the minimum interval for all of them. Our take: define one task and have it call your jobs in order. It is easier to reason about and there is no interval surprise.

On iOS, a task can run for minutes, but the system can interrupt it at any time. BackgroundTask.addExpirationListener gives you a callback right before that happens so you can save progress, and it is iOS only. Write the work so it can stop halfway and pick up cleanly on the next run. A sync that marks each item done as it goes survives this. One big all-or-nothing request does not.

Step 4: Test it without waiting for the system

Waiting for a real run is a terrible way to debug. Instead, add a button behind a __DEV__ check that calls BackgroundTask.triggerTaskWorkerForTestingAsync. On Android it runs all registered tasks directly, and on iOS it invokes BGTaskScheduler. It works only in debug builds, so it cannot help you in TestFlight or production.

  1. Install your development build on a physical iPhone. The Background Tasks API is not available on iOS simulators, so a simulator test proves nothing.
  2. Have the task write the current time to storage, and show that value on a debug screen. Logs are easy to miss, a timestamp is not.
  3. Tap your test button and confirm the timestamp changes.
  4. On Android, you can inspect the job with adb shell dumpsys jobscheduler and force it with adb shell cmd jobscheduler run -f, followed by your package name and the job ID. Put the app in the background first, because the task will not run while it is in the foreground.
  5. Then ship a [TestFlight build](/blog/testflight-beta-testing-guide-for-expo-apps), keep writing the timestamp, and leave the phone alone overnight. This is the only check that shows real scheduling on a real device.

Step 5: Pick the right tool for the job

Most background task bugs are really wrong-tool bugs. The API is deliberately loose about timing to protect battery life, so anything your user is counting on at a precise moment needs a different path.

Is a background task the right choice?

You want toUseWhy
Upload queued changes eventuallyBackground taskTiming is flexible, and the data can wait
Open the app to fresh contentBackground task, plus a fetch on openThe task is a bonus, the fetch on open is the guarantee
Alert a user right nowPush notificationYour server decides the moment, not the phone
Sync the moment the app opens or reconnectsForeground codeThe app is already running, so nothing has to wake it
Run something every few minutesRethink it15 minutes is the floor, and iOS may stretch it much further

For the alert case, see [how to add push notifications to your Expo app](/blog/how-to-add-push-notifications-to-your-expo-app). For the sync case, see [how to add offline support to your Expo app](/blog/how-to-add-offline-support-to-your-expo-app).

Our take: design the app so it is correct if the background task never runs at all. Then every run is a speed boost, not a dependency. Never put a promise like "synced every 15 minutes" in your app or your store listing, because you do not control that. If you are syncing to a backend, the same thinking applies to [your Supabase setup](/blog/how-to-set-up-supabase-with-expo): the source of truth should not depend on a run happening.

If you find a tutorial using expo-background-fetch, skip it. That package is deprecated, is not receiving patches, and will be removed in an upcoming release. expo-background-task is its replacement.

Have Claude Code build it for you

Open your project in the Claude Code desktop app and describe the behavior you want. Left alone, AI-written code tends to reach for the deprecated expo-background-fetch, define the task inside a component, or assume the interval is exact. A prompt that heads off all three:

The 12 hours in that prompt matches the default, and it is a sensible place to start because the system will not honor anything tight on iOS anyway. Change it only if you have a reason. Then add a line to your [CLAUDE.md](/blog/claude-md-for-expo-apps) such as "Background work: expo-background-task only, defined in tasks.ts, app must stay correct if it never runs" so a later session does not undo it.

The short version

To run background tasks in your Expo app: install expo-background-task and expo-task-manager, define the task at module scope, register it once with a realistic minimumInterval, and test on a physical device in a development build. Remember that the system chooses when it runs, that a force quit on iOS stops it until the app is reopened, and that your app should work fine if it never runs at all.

If you are building your first iOS app with Claude Code and Expo and want feedback on it before App Review, bring it to App Store Launch Club. Members share their builds and help each other get unstuck, and the [curriculum](/curriculum) covers the full path from first build to first users. If you are working on how your app behaves when conditions are not perfect, our guide to [checking the network connection](/blog/how-to-check-network-connection-in-your-expo-app) pairs well with this one. Join at applaunchclub.co for $9 a month.

Free app-building tips, straight to your inbox

Short, practical drops on app ideas, validating fast, store listings, and passing app review. No spam, unsubscribe anytime.

Frequently asked questions

How do I run a background task in Expo?

Install expo-background-task and expo-task-manager, define the task with TaskManager.defineTask at module scope, and call BackgroundTask.registerTaskAsync with the same name. The task returns BackgroundTaskResult.Success or BackgroundTaskResult.Failed when it finishes.

Why is my Expo background task not running?

The most common reasons are testing in Expo Go, testing on an iOS simulator, defining the task inside a component, or simply not waiting long enough, since the system chooses the time. The task also needs enough battery and a network connection, and on iOS it stops if the user swipes the app away. Use triggerTaskWorkerForTestingAsync in a debug build on a physical device to rule these out.

How often can an Expo background task run?

The default is once every 12 hours and the lowest minimumInterval is 15 minutes. That value is a minimum delay, not a schedule. On iOS, short intervals are often ignored and tasks typically run in windows such as overnight.

Does expo-background-task work in Expo Go?

Not for real testing. The module is listed as included in Expo Go, but TaskManager is not available there on Android and does not support background execution on iOS. Use a development build.

Should I use expo-background-fetch or expo-background-task?

Use expo-background-task. expo-background-fetch is deprecated, is not receiving patches, and will be removed in an upcoming release.

Do background tasks keep running after the user closes the app?

Moving the app to the background is fine, and tasks resume after a reboot or after the system stops the app. If the user kills the app, tasks stop until it is reopened. On iOS, swiping the app away counts as killing it. On Android, swiping it away usually does not fully stop it, though this varies by device maker.

Last reviewed by David on November 8, 2026

David

Written by

David

Founder and app builder

Keep reading

ExpoClaude Code

How to Add Notification Actions to Your Expo App

To add notification actions to an Expo app, register a category with Notifications.setNotificationCategoryAsync, give it action buttons (and optionally a text reply), set categoryIdentifier on the notification, then read response.actionIdentifier in a response listener. Here is every action option, how to handle taps when the app was closed, the Android and iOS differences, and a Claude Code prompt that wires it all up.

David 8 min
Read article
ExpoClaude Code

How to Schedule Local Notifications in Your Expo App

To schedule local notifications in an Expo app, install expo-notifications, set a notification handler, ask for permission, create an Android channel, then call scheduleNotificationAsync with your content and a trigger like DAILY, WEEKLY or DATE. Here is every trigger type, how to cancel and list what is scheduled, why Android reminders arrive late, and a Claude Code prompt that builds the whole reminder flow.

David 8 min
Read article

Ready to build it yourself?

Join App Store Launch Club, the #1 community for building and launching apps, for $9/month.

← Back to the blog