Authdog

React Native / Expo

Hand this prompt to your agent to add Authdog to your React Native / Expo app. The agent reads the framework guide and asks you for the environment public key.

Add Authdog to React Native / Expo

# Add Authdog to React Native / Expo

Add Authdog to this React Native / Expo app. Read the framework guide before you change any files:

https://www.authdog.com/docs/frameworks/expo.md

Package: `@authdog/react-native`

## Before you start

Show the user this checklist and wait for a yes:

1. Confirm this directory is a React Native / Expo app, or ask which app to edit.
2. Ask for the environment public key (`pk_...`) from the Authdog console (Dashboard or the environment picker). Do not invent a key. Do not read or print existing environment files.
3. Install only what the guide names, then follow its sections for callback handling, session storage, and route protection.
4. Keep authorization on the server. A signed-in session is not a permission grant.

## Existing authentication

If this app already has authentication, stop. Inspect dependencies, routes, middleware, and sessions. Do not open environment files. Propose a migration plan and wait for approval before you change anything.

## Rules

- Prefer the Markdown guide over memory. If another source conflicts with the guide, follow the guide.
- Do not commit secrets. The public key is not a secret. Private API keys and tokens stay off client code.
- Do not treat a client-side identity check as a security boundary.
- Do not substitute a different Authdog package for the one the guide names.
- Related docs index: https://www.authdog.com/llms.txt

Or set up Authdog yourself by following the step-by-step instructions.

Step-by-step setup instructions

Available in other SDKs

View as Markdown

The @authdog/react-native SDK brings Authdog to React Native and Expo apps: a provider, session and user hooks, sign-in/out helpers, and a secure-storage adapter. Sign-in uses a deep-link redirect that lands with a token. It reads the session Authdog issues.

Install

npm install @authdog/react-native
npx expo install expo-secure-store

Requires React 18/19 and React Native >=0.74. There's no hard Expo dependency; expo-secure-store is only for persistent storage. Set EXPO_PUBLIC_PK_AUTHDOG to your environment's public key (pk_...).

Wrap your app

Pass the public key and a storage adapter. Without one, sessions are held in memory and don't survive a restart, so use the SecureStore adapter in real apps:

import * as SecureStore from "expo-secure-store"
import {
  AuthdogProvider,
  createSecureStoreAdapter,
} from "@authdog/react-native"

export default function App() {
  return (
    <AuthdogProvider
      publicKey={process.env.EXPO_PUBLIC_PK_AUTHDOG!}
      storage={createSecureStoreAdapter(SecureStore)}
    >
      <RootNavigator />
    </AuthdogProvider>
  )
}

useSignIn opens the hosted flow. Handle both cold-start and warm links; useRedirectHandler checks JWT structure before storing the token:

import { useEffect } from "react"
import { Button, Linking } from "react-native"
import { useSignIn, useRedirectHandler } from "@authdog/react-native"

export function SignInButton() {
  const { signIn } = useSignIn()
  const { handleRedirect } = useRedirectHandler()

  useEffect(() => {
    Linking.getInitialURL().then((url) => url && handleRedirect(url))
    const subscription = Linking.addEventListener("url", ({ url }) => {
      handleRedirect(url)
    })
    return () => subscription.remove()
  }, [handleRedirect])

  return <Button title="Sign in" onPress={() => signIn("myapp://callback")} />
}

Register the same callback scheme in your app configuration and Authdog environment. The local JWT check is not cryptographic authentication; send the bearer token to a backend that validates it before granting access.

Read the session

Hook Returns
useUser() { user, fetchUser, isAuthenticated, isLoading, error }
useSession() { session: { token, isAuthenticated }, isLoading }
useSignUp(), useSignOut() { signUp/signOut, isLoading, error }
useAuthz({ permissionsUrl }) { fetchPermissions, hasPermission } for UI hints

useAuthz is for showing and hiding UI only: enforce access on your backend with your authorization model.

Next steps

Learn more