Skip to content

feat: add expo-example app#76

Merged
andrascodes merged 3 commits into
mainfrom
andras/feat-add-expo-example-app
May 13, 2026
Merged

feat: add expo-example app#76
andrascodes merged 3 commits into
mainfrom
andras/feat-add-expo-example-app

Conversation

@andrascodes
Copy link
Copy Markdown
Collaborator

@andrascodes andrascodes commented Apr 1, 2026

This PR is part of a stack created with Aviator.

Closes FS-1929

Added an expo-example app to test wallet-react. I needed to do a couple stuff to make Expo/Metro work with the monorepo and the packages:

  1. Adding babel.config.js to get rid of the import.meta error

Added nodeLinker: hoisted to the workspace file and the NPM config file.
- This is needed to make the example app work, however, it can cause drawbacks with module resolution. (Source) We can discuss the best strategy here. On one hand, the example apps make it a lot easier to test the packages while developing. It's not a good option to install local modules in Expo as it's cumbersome and requires frequent bundle cache and node_modules resets. On the other hand, I do understand the drawbacks can be more annoying.

Hoisted deps alone did not work to resolve multiple package versions so I had to add overrides here.

Got inspired from Omar's PR and I added a Metro config instead to link to the correct modules. This might make some new package installs brittle so we need to keep extending it but it beats having to make global dep management modifications to the repo for the sake of an example app.
Claude's explanation:

⏺ The metro config solves a problem caused by pnpm in monorepos: duplicate package copies.

When packages/react and apps/expo-example both depend on wagmi, pnpm installs two separate copies in its .pnpm store (even with node-linker=hoisted) because their transitive dependency trees differ slightly. Metro then bundles both copies, meaning WagmiProvider from one copy creates a React context that useConfig from the other copy can't find.

What the config does:

config.resolver.resolveRequest = (context, moduleName, platform) => {

It intercepts Metro's module resolution. For every import in the bundle, this function decides where the module comes from.

Two categories of overrides:

  1. workspaceSingletons (react, wagmi, @wagmi/core, @tanstack/react-query, react-dom) — Only redirected when the import originates from packages/* (your workspace libraries). This is scoped because redirecting these globally would break wagmi's own internal imports of @wagmi/core etc.
  2. globalSingletons (tslib) — Redirected for ALL imports regardless of origin. Safe because tslib is a standalone utility with no internal dependencies.

How the redirect works:

return context.resolveRequest(
{ ...context, originModulePath: appPackageJson },
moduleName,
platform,
)

It lies to Metro about where the import is coming from — instead of resolving from packages/react/dist/..., it resolves as if the import came from apps/expo-example/package.json. Metro then walks up from there, finds apps/expo-example/node_modules/wagmi, and uses the app's copy. This ensures a single copy of each package ends up in the bundle.

@OmarBasem OmarBasem mentioned this pull request Apr 3, 2026
@andrascodes andrascodes force-pushed the andras/feat-add-expo-example-app branch from f0d1057 to accf679 Compare April 7, 2026 11:21
@andrascodes andrascodes force-pushed the andras/fix-react-race-condition-between-initialize-and-isauthorized-in-rn branch from 9134f2e to 19af0fe Compare April 7, 2026 11:21
@andrascodes andrascodes force-pushed the andras/feat-add-expo-example-app branch from accf679 to d265505 Compare April 7, 2026 16:17
@andrascodes andrascodes force-pushed the andras/fix-react-race-condition-between-initialize-and-isauthorized-in-rn branch from 19af0fe to 67fc62b Compare April 7, 2026 16:17
@andrascodes andrascodes marked this pull request as ready for review April 7, 2026 16:55
@andrascodes andrascodes force-pushed the andras/feat-add-expo-example-app branch from d265505 to ef7beaa Compare April 20, 2026 10:11
@andrascodes andrascodes force-pushed the andras/fix-react-race-condition-between-initialize-and-isauthorized-in-rn branch from 67fc62b to 7e8b5c9 Compare April 20, 2026 10:11
@andrascodes andrascodes force-pushed the andras/feat-add-expo-example-app branch from ef7beaa to a5a4190 Compare April 24, 2026 17:57
@andrascodes andrascodes force-pushed the andras/fix-react-race-condition-between-initialize-and-isauthorized-in-rn branch from 7e8b5c9 to 6d49f74 Compare April 24, 2026 17:57
Comment thread apps/expo-example/lib/passkeyStamper.ts Outdated
Comment thread apps/expo-example/lib/passkeyStamper.ts Outdated
Comment thread pnpm-workspace.yaml Outdated
Copy link
Copy Markdown
Collaborator

@SahilVasava SahilVasava left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks solid. Three inline nits — naming, getPublicKey returning null, and lost yaml comments. Nothing blocking.

@andrascodes andrascodes force-pushed the andras/fix-react-race-condition-between-initialize-and-isauthorized-in-rn branch from 6d49f74 to e37a38e Compare May 4, 2026 13:12
@andrascodes andrascodes force-pushed the andras/feat-add-expo-example-app branch 2 times, most recently from 7511324 to a8f78a3 Compare May 4, 2026 16:56
@andrascodes andrascodes force-pushed the andras/fix-react-race-condition-between-initialize-and-isauthorized-in-rn branch from e37a38e to 72d702a Compare May 4, 2026 16:56
@andrascodes andrascodes force-pushed the andras/feat-add-expo-example-app branch from a8f78a3 to cfa9016 Compare May 5, 2026 11:02
@andrascodes andrascodes merged commit a21aef4 into main May 13, 2026
21 of 23 checks passed
OmarBasem pushed a commit that referenced this pull request May 14, 2026
OmarBasem pushed a commit that referenced this pull request May 14, 2026
OmarBasem pushed a commit that referenced this pull request May 14, 2026
OmarBasem pushed a commit that referenced this pull request May 14, 2026
OmarBasem pushed a commit that referenced this pull request May 14, 2026
OmarBasem pushed a commit that referenced this pull request May 14, 2026
OmarBasem pushed a commit that referenced this pull request May 14, 2026
OmarBasem pushed a commit that referenced this pull request May 14, 2026
OmarBasem pushed a commit that referenced this pull request May 14, 2026
OmarBasem pushed a commit that referenced this pull request May 14, 2026
OmarBasem pushed a commit that referenced this pull request May 14, 2026
OmarBasem pushed a commit that referenced this pull request May 14, 2026
OmarBasem pushed a commit that referenced this pull request May 14, 2026
OmarBasem pushed a commit that referenced this pull request May 14, 2026
OmarBasem pushed a commit that referenced this pull request May 14, 2026
OmarBasem pushed a commit that referenced this pull request May 14, 2026
OmarBasem pushed a commit that referenced this pull request May 14, 2026
OmarBasem pushed a commit that referenced this pull request May 14, 2026
OmarBasem pushed a commit that referenced this pull request May 14, 2026
OmarBasem pushed a commit that referenced this pull request May 14, 2026
OmarBasem pushed a commit that referenced this pull request May 14, 2026
OmarBasem pushed a commit that referenced this pull request May 14, 2026
OmarBasem pushed a commit that referenced this pull request May 14, 2026
OmarBasem pushed a commit that referenced this pull request May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants