---
name: snap4id-integrate-embed
description: Add the Snap4ID photo flow to a React Native / Expo app with @snap4id-sdk/app-embed (client, flow screen, resume, plugins, delivery). Use when asked to integrate, embed or add Snap4ID ID photos to an app.
---

# Integrate the Snap4ID embed

1. Ask for (or find in config) the partner id (from Snap4ID onboarding, `/go-live/onboarding/`; none yet: develop
   against the fake page with partner `test-verifier`, steps 7–8), the store product ids, and the two choices: who buys (`built-in` by
   default) and who checks the purchase (Snap4ID by default; or the partner, on our verifier server or in its own
   backend).
2. Install: `npx expo install expo-dev-client react-native-webview expo-iap expo-file-system expo-media-library
   expo-sharing expo-constants`, then `npm install @snap4id-sdk/app-embed`. Add plugins
   `['@snap4id-sdk/app-embed', 'expo-iap']` to the Expo config (`app.json` `expo.plugins` in the default template;
   keep the entries `npx expo install` added; Polish usage texts via the plugin options for a Polish app). The app needs
   a development build (`npx expo run:ios` / `run:android`). The steps below assume Expo Router; the default SDK 58
   template keeps routes in `src/app/` (root layout `src/app/_layout.tsx`, a tab layout to replace with a Stack or to
   keep beside a full-screen `flow` route). Without Expo Router (e.g. the `blank` template), use the root component
   and a full-screen screen of the app's own navigator.
3. Create one module exporting the client:
   `createSnap4IdClient({ partnerId, purchases: 'built-in', onCompleted, onError })` (no product ids: the page names
   the product from the partner's onboarding and the component looks up its store price). In `onCompleted`,
   call `client.downloadArtifacts(completion)` (or the app's own storage) idempotently by `completion.jobId`.
4. In the root layout: `client.start()` once in an effect, and render `<Snap4IdResume client={client} />`.
5. Add a full-screen route below an opaque header (Expo Router: `<Stack screenOptions={{ headerTransparent: false }}>`;
   a transparent header covers the WebView) rendering `<Snap4IdFlow client={client} onClose={…} onStateChange={({ title }) => …} />`,
   with `consent={{ statistics }}` from the app's consent state if it has one. To resume a job pass `jobId`.
6. A list screen of delivered photos from `client.downloads` (`list()` / `forJob(jobId)`, each with `localUri`); Save /
   Share through `client.files.save(jobId, code)` / `share(jobId, code)`. Iterate `completion.artifacts` (codes come
   from the document metadata; don't hard-code them). Links expire after 30 days: store the files.
7. For simulator testing only: a single dev-only file exporting `{ builtInStore: createDevFakeStore() }` (from
   `@snap4id-sdk/app-embed/dev`) and, when wanted, an `origin` from an `EXPO_PUBLIC_*` variable of the app's own;
   `require` it only under `__DEV__` and pass it as the second argument of `createSnap4IdClient`. Copy the two files of
   `/test/fake-store/` ("Simulator runs with the fake store"), and note to delete the dev file before release.
8. Build and run against the SDK's fake Snap4ID page (`npm run fake-page` in the SDK checkout; partner
   `test-verifier`, origin `http://127.0.0.1:8090`, Android emulator `http://10.0.2.2:8090`); start Metro with the
   app's `EXPO_PUBLIC_*` settings (e.g. `EXPO_PUBLIC_SNAP4ID_ORIGIN`, `EXPO_PUBLIC_SNAP4ID_PARTNER_ID`,
   `EXPO_PUBLIC_SNAP4ID_TEST_STORE=1`); buy with the fake store; kill the app after buying and check the photo still
   arrives. To see a finished app first: skill `snap4id-try-example`.

Do not finish purchases yourself, do not set `origin` for release builds, do not wrap the flow in an iframe.
