# Add Deep Links to an Expo App

Yes. An agent adds universal links and App Links to an Expo Router app, guards the linked screen behind sign-in, keeps the destination through login and tests it.

[Run this on Rush](https://cloud.getrush.ai/run/add-deep-links/expo/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads the routing and the build configuration before adding a domain. In an app laid out like obytes/react-native-template-obytes, `app.config.ts` sets `scheme: Env.EXPO_PUBLIC_SCHEME`, `ios.bundleIdentifier: Env.EXPO_PUBLIC_BUNDLE_ID` and `android.package: Env.EXPO_PUBLIC_PACKAGE`, and `env.ts` validates those with zod and resolves them per `EXPO_PUBLIC_APP_ENV`: `com.obytes.development`, `com.obytes.preview` and `com.obytes`, with the scheme `obytesApp` for development and production and `obytesApp.preview` for preview. The routes under `src/app/` are an Expo Router tree: `_layout.tsx` with a stack of `(app)`, `onboarding` and `login`, the tabs in `(app)/_layout.tsx`, which redirect to `/onboarding` while `useIsFirstTime` is true and to `/login` while the auth store's `status` is `signOut`, and `feed/[id].tsx`, which renders `PostDetailScreen` from `useLocalSearchParams<{ id: string }>()`. The custom scheme already opens `obytesApp://feed/42` into that screen; what is missing is `https://` links, and the fact that `feed/` sits outside the `(app)` group, so the redirects in the tabs layout never run for it.

The domain becomes an environment value like the rest: `EXPO_PUBLIC_LINK_DOMAIN` in `env.ts`, validated as a hostname, with one value per environment so a preview build claims a preview host. `app.config.ts` gains `ios.associatedDomains: ['applinks:' + domain]` and an `android.intentFilters` entry with `autoVerify: true`, `action: 'VIEW'`, `data` of scheme `https`, that host and `pathPrefix: '/feed'`, and the `BROWSABLE` and `DEFAULT` categories. The files the host must serve are written as templates under `public/.well-known/`: an `apple-app-site-association` naming the Team ID placeholder and the bundle identifier with the `/feed/*` path, and an `assetlinks.json` naming the package and a placeholder for the SHA-256 certificate fingerprint, which the pull request says to read from the EAS credentials for each build profile in `eas.json`.

The guard moves to where the linked screen lives. `src/app/feed/_layout.tsx` is new and applies the same two redirects as the tabs layout, so a signed-out person who taps a link lands on login rather than on a post fetched with no token. The redirect carries the destination: `Redirect` to `/login` with a `next` param set to the current path, and `login-screen.tsx`, which today calls `signIn` and `router.push('/')`, reads `next` with `useLocalSearchParams` and replaces to it when it is a path inside the app, else to `/`. The onboarding redirect does the same, so a first install from a link ends on the post after the carousel.

The tests follow the jest-expo setup in `jest.config.js` and the existing `*.test.tsx` files. `src/app/feed/deep-links.test.tsx` uses Expo Router's testing library to render the tree with an `initialUrl` of `/feed/42` while the auth store says `signIn` and asserts the post screen mounts with id `42`; renders it with `signOut` and asserts the login screen is on with `next` equal to `/feed/42`; and renders `/feed/42` after a sign-in through the login form and asserts the post screen. A config test calls the exported function in `app.config.ts` with the preview environment and asserts the associated domain and the intent filter host. `pnpm check-all`, which runs lint, type-check, the translation lint and jest, ends the run.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add universal links and Android App Links to this Expo Router app for post pages. Read app.config.ts, env.ts, eas.json, src/app/_layout.tsx, src/app/(app)/_layout.tsx, src/app/feed/[id].tsx, src/app/login.tsx, src/features/auth/login-screen.tsx, src/features/auth/use-auth-store.tsx, src/lib/hooks/use-is-first-time.tsx and jest.config.js first. Add EXPO_PUBLIC_LINK_DOMAIN to env.ts with one hostname per environment. In app.config.ts add ios.associatedDomains for that host and an android intentFilters entry with autoVerify, https, that host and pathPrefix /feed. Write template apple-app-site-association and assetlinks.json files under public/.well-known/ with placeholders for the Team ID and certificate fingerprint. Add src/app/feed/_layout.tsx with the same onboarding and sign-in redirects as the tabs layout, passing the current path as a next param, and make the login and onboarding screens return to next when it is an in-app path. Write jest tests with Expo Router's testing library for /feed/42 signed in, signed out, and after signing in, plus a test of the config function for the preview environment. Run pnpm check-all and open a pull request with the output and the steps to verify the domain files on each platform.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

The pull request changes `app.config.ts`, `env.ts` and `src/features/auth/login-screen.tsx`, adds `src/app/feed/_layout.tsx`, the two files under `public/.well-known/` and the two test files, and touches no native folder, since the app is prebuilt from the config. Its description pastes the `pnpm check-all` output with the new tests named, the resolved config for the preview environment, and the `npx uri-scheme open` command to try a link on a simulator.

A tap on `https://<domain>/feed/42` opens the post in the installed app once the domain files are live and the app has been rebuilt, and falls through to the browser where it is not installed. A signed-out person goes through login and arrives on the post, and the custom scheme keeps working as before for development.

Before merging, a reviewer fills in the Team ID and the certificate fingerprints, deploys the two files with the right content types, and rebuilds through EAS, because associated domains are read at install time and a running build does not pick them up.

## Run it on every mobile app with public pages

A team with several Expo apps sends this body once per repository to `POST /o/{org}/sessions` from a script, each with its own repository in `resources` and a `request_id` that is a UUID v5 of the repository's full name, so a retried call returns the run already started. Each run reads its own router: an app on React Navigation without Expo Router gets a `linking` config instead of file routes, one whose guarded screens already sit inside a group gets only the domain configuration, and one with a `web` output gets the domain files placed where its static export serves them.

Each run opens its own pull request on its own branch. `GET /o/{org}/sessions` lists them newest first and the key's `webhook_url` receives a `run.completed` per run with the pull request in `result`, so the person who started the batch reads every test run from one place.

## Why run it on Rush?

Deep links fail at the seams: a route outside the guarded group, a login that forgets where the person was going, a domain claimed by the production build but not the preview one. The agent reads the route tree and the per-environment identifiers before writing, and its tests render the real router with a real initial URL in its sandbox rather than asserting on a config object alone.

The run keeps every command and its output, so the reviewer reads the jest run and the resolved config without Xcode, Android Studio or a device. Several apps can be linked at once, each in its own sandbox, and one that already has associated domains gets only the guard and the return-to-destination fix.

## Frequently asked questions

### Does this need a native rebuild?

Yes. Associated domains and intent filters are read from the native project at install, and `app.config.ts` feeds them to `expo prebuild`, so the change lands in the next EAS build for each profile in `eas.json`. A development client already on a device keeps using the custom scheme until it is rebuilt.

### What goes in the two well-known files?

The iOS file names the Team ID and bundle identifier with the paths the app claims, and the Android file names the package and the signing certificate's SHA-256 fingerprint. The agent writes both with placeholders and the pull request lists the EAS commands that print each value, because a run cannot read your signing credentials.

### Why a new layout under feed?

Because `feed/[id].tsx` and `feed/add-post.tsx` sit outside `(app)`, and Expo Router only runs a layout's redirects for routes beneath it. A layout at `feed/_layout.tsx` is the smallest change that guards both without moving files and breaking existing hrefs.

### Can the link carry an untrusted next path?

The login screen only follows `next` when it starts with `/` and matches a route in the app, and otherwise goes to `/`. A link cannot send a person to an external URL or to a screen the router does not know.

## More Expo jobs

- [Add an EAS Build Workflow on GitHub Actions to an Expo App](https://getrush.ai/run/add-eas-build-workflow/expo/)
- [Set Up GitHub Actions CI for an Expo App](https://getrush.ai/run/add-github-actions-ci/expo/)
- [Add i18n to an Expo App](https://getrush.ai/run/add-i18n/expo/)

## The same job on other stacks

- [Add Deep Links to a Flutter App](https://getrush.ai/run/add-deep-links/flutter/)
- [Add Deep Links to a React Native App](https://getrush.ai/run/add-deep-links/react-native/)
- [Add Deep Link Handling to a Tauri App](https://getrush.ai/run/add-deep-links/tauri/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
