{"id":49099284,"url":"https://github.com/joshuabaker/authkit-react-native","last_synced_at":"2026-04-20T23:00:32.598Z","repository":{"id":345127989,"uuid":"1184466743","full_name":"joshuabaker/authkit-react-native","owner":"joshuabaker","description":"🔐 WorkOS AuthKit for Expo / React Native","archived":false,"fork":false,"pushed_at":"2026-04-14T05:51:45.000Z","size":716,"stargazers_count":6,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-14T07:32:48.808Z","etag":null,"topics":["authkit","expo","expo-auth","expo-auth-session","react-native","react-native-authentication","workos","workos-authkit"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joshuabaker.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-17T16:03:52.000Z","updated_at":"2026-04-14T05:50:15.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/joshuabaker/authkit-react-native","commit_stats":null,"previous_names":["joshuabaker/authkit-react-native"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/joshuabaker/authkit-react-native","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshuabaker%2Fauthkit-react-native","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshuabaker%2Fauthkit-react-native/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshuabaker%2Fauthkit-react-native/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshuabaker%2Fauthkit-react-native/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joshuabaker","download_url":"https://codeload.github.com/joshuabaker/authkit-react-native/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshuabaker%2Fauthkit-react-native/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32069440,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T21:26:33.338Z","status":"ssl_error","status_checked_at":"2026-04-20T21:26:22.081Z","response_time":94,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authkit","expo","expo-auth","expo-auth-session","react-native","react-native-authentication","workos","workos-authkit"],"created_at":"2026-04-20T23:00:20.943Z","updated_at":"2026-04-20T23:00:32.590Z","avatar_url":"https://github.com/joshuabaker.png","language":"TypeScript","readme":"# AuthKit for React Native\n\nWorkOS AuthKit integration for React Native, built on Zustand and Expo modules.\n\n- 🔒 Secure token storage (Keychain/Keystore)\n- 🔄 Automatic session restoration and token refresh\n- 🔏 PKCE for added security\n- 🧩 Zustand-based — no nested providers or layouts required\n\n## Installation\n\n```bash\nnpx expo install authkit-react-native zustand expo-auth-session expo-secure-store expo-web-browser @react-native-async-storage/async-storage\n```\n\n## Usage\n\n### Create the hook\n\nCreate a `useAuth` hook that your app imports everywhere. The store is created at module scope so the session begins restoring immediately on app launch.\n\n```typescript\n// hooks/useAuth.ts\nimport { createAuthStore } from \"authkit-react-native\";\nimport { useStore } from \"zustand\";\n\nconst authStore = createAuthStore({\n  // Provide authorizationEndpoint or clientId\n  authorizationEndpoint: \"https://api.example.com/v1/auth/authorize\",\n  tokenEndpoint: \"https://api.example.com/v1/auth/token\",\n  revocationEndpoint: \"https://api.example.com/v1/auth/revoke\",\n});\n\nexport function useAuth() {\n  return useStore(authStore);\n}\n```\n\n### Protected routes\n\nUse `Stack.Protected` to gate routes based on auth state. Because the store lives outside React, there's no provider to wrap your app in — just call `useAuth()` in your root layout.\n\n\u003e Requires Expo SDK 53+ (Expo Router v5).\n\n```tsx\n// app/_layout.tsx\nimport { useAuth } from \"@/hooks/useAuth\";\nimport { Loading } from \"@/components/Loading\";\nimport { Stack } from \"expo-router\";\n\nexport default function RootLayout() {\n  const { user, isLoading } = useAuth();\n\n  if (isLoading) return \u003cLoading /\u003e;\n\n  return (\n    \u003cStack\u003e\n      \u003cStack.Protected guard={!user}\u003e\n        \u003cStack.Screen name=\"sign-in\" /\u003e\n      \u003c/Stack.Protected\u003e\n\n      \u003cStack.Protected guard={!!user}\u003e\n        \u003cStack.Screen name=\"(app)\" /\u003e\n      \u003c/Stack.Protected\u003e\n    \u003c/Stack\u003e\n  );\n}\n```\n\n### Sign in\n\nCall `signIn()` to open the WorkOS AuthKit sign-in page. Returns `true` on success, `false` if the user cancelled.\n\n```tsx\nimport { useAuth } from \"@/hooks/useAuth\";\n\nfunction SignInScreen() {\n  const { signIn } = useAuth();\n\n  return (\n    \u003c\u003e\n      \u003cButton title=\"Sign in\" onPress={() =\u003e signIn()} /\u003e\n      \u003cButton\n        title=\"Sign up\"\n        onPress={() =\u003e signIn({ screenHint: \"sign-up\" })}\n      /\u003e\n    \u003c/\u003e\n  );\n}\n```\n\n### Sign out\n\n`signOut()` revokes the token and clears storage. It does not show any confirmation UI — add that in your app:\n\n```tsx\nimport { useAuth } from \"@/hooks/useAuth\";\nimport { Alert } from \"react-native\";\n\nfunction SignOutButton() {\n  const { user, signOut } = useAuth();\n\n  const handleSignOut = () =\u003e {\n    Alert.alert(\n      `Are you sure you want to sign out as ${user.email}?`,\n      undefined,\n      [\n        { text: \"Cancel\", style: \"cancel\" },\n        { text: \"Sign out\", style: \"destructive\", onPress: () =\u003e signOut() },\n      ],\n    );\n  };\n\n  return \u003cButton title=\"Sign out\" onPress={handleSignOut} /\u003e;\n}\n```\n\n## Configuration\n\n| Option                  | Required | Default             | Description                                                               |\n| ----------------------- | -------- | ------------------- | ------------------------------------------------------------------------- |\n| `authorizationEndpoint` | \\*       | WorkOS default      | OAuth authorize URL. Required unless `clientId` is provided.              |\n| `clientId`              | \\*       | —                   | WorkOS client ID. Required when using the default authorization endpoint. |\n| `tokenEndpoint`         | Yes      | —                   | Token exchange URL.                                                       |\n| `revocationEndpoint`    | Yes      | —                   | Token revocation URL.                                                     |\n| `redirectUri`           | No       | `makeRedirectUri()` | OAuth redirect URI.                                                       |\n| `storageKeyPrefix`      | No       | `\"workos\"`          | Prefix for SecureStore/AsyncStorage keys.                                 |\n| `devMode`               | No       | `false`             | Logs errors to the console when enabled.                                  |\n\n## Examples\n\nSee the [`examples/`](examples/) directory for complete, copy-paste-ready projects:\n\n- **[Expo](examples/expo/)** — Minimal client app with `useAuth` hook\n- **[Hono](examples/hono/)** — Auth proxy server on Cloudflare Workers\n- **[Next.js](examples/nextjs/)** — Auth proxy server with App Router route handlers\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshuabaker%2Fauthkit-react-native","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoshuabaker%2Fauthkit-react-native","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshuabaker%2Fauthkit-react-native/lists"}