React Native quickstart
Add Wocha sign-in to a React Native or Expo app using @wocha/react-native with OAuth PKCE and deep link callbacks.
Add Wocha sign-in to a React Native or Expo app using @wocha/react-native with OAuth PKCE and deep link callbacks.
Prerequisites
- Node.js 18+
- Expo SDK 49+ or React Native 0.71+
- A Wocha project with a public OAuth application (Wocha Console)
- Redirect URI registered:
myapp://auth/callback
What you'll build
A mobile app with deep-link OAuth callbacks, secure session storage, and sign-in screens.
Welcome back
After sign-in
✓ Session stored securely
✓ User profile available in your app
✓ Organisation context ready for multi-tenant features
Installation
pnpm add @wocha/react-nativeThen install Expo peer dependencies:
Environment variables
Expo supports public env vars prefixed with EXPO_PUBLIC_. Create .env:
App configuration
Add your URL scheme to app.json:
Register myapp://auth/callback as a redirect URI in the Wocha Console.
Provider setup
Wrap your app in App.tsx:
WochaProvider automatically:
- Restores sessions from secure storage on launch
- Listens for deep link callbacks via
expo-linking(or React NativeLinking) - Refreshes access tokens in the background
Sign-in screen
Create screens/HomeScreen.tsx:
Calling your API
Attach the access token to API requests:
Testing the integration
-
Start the app:
-
Open on a device or simulator (deep links behave most reliably on a real device).
-
Tap Sign in — the in-app browser opens the hosted Wocha login UI.
-
Complete login — the app receives
myapp://auth/callback?code=…&state=…and exchanges the code for tokens. -
Force-quit and reopen the app — the session should restore from secure storage.
Troubleshooting
| Issue | Fix |
|---|---|
redirect_uri_mismatch | Ensure myapp://auth/callback is registered in the Console |
| Session not persisting | Install expo-secure-store |
| Callback not received | Verify scheme in app.json matches your redirect URI |
Next steps
- SDK reference — hooks, server helpers, and configuration options
- Webhooks overview — receive user and session lifecycle events
- Common patterns — protect routes, org switching, and role-based UI