@better-auth/expo 1.2.12 → 1.3.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +95 -0
  2. package/package.json +17 -6
package/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # Better Auth Expo Plugin
2
+
3
+ This plugin integrates Better Auth with Expo, allowing you to easily add authentication to your Expo (React Native) applications. It supports both Expo native and web apps.
4
+
5
+ ## Installation
6
+
7
+ To get started, install the necessary packages:
8
+
9
+ ```bash
10
+ # Using npm
11
+ npm install better-auth @better-auth/expo
12
+
13
+ # Using yarn
14
+ yarn add better-auth @better-auth/expo
15
+
16
+ # Using pnpm
17
+ pnpm add better-auth @better-auth/expo
18
+
19
+ # Using bun
20
+ bun add better-auth @better-auth/expo
21
+ ```
22
+
23
+ You will also need to install `expo-secure-store` for secure session and cookie storage in your Expo app:
24
+
25
+ ```bash
26
+ npm install expo-secure-store
27
+ # or
28
+ yarn add expo-secure-store
29
+ # or
30
+ pnpm add expo-secure-store
31
+ # or
32
+ bun add expo-secure-store
33
+ ```
34
+
35
+ ## Basic Usage
36
+
37
+ ### Configure the Better Auth Backend
38
+
39
+ Ensure you have a Better Auth backend set up. You can follow the main [Installation Guide](https://www.better-auth.com/docs/installation).
40
+
41
+ Then, add the Expo plugin to your Better Auth server configuration (e.g., in your `auth.ts` or `lib/auth.ts` file):
42
+
43
+ ```typescript
44
+ // lib/auth.ts
45
+ import { betterAuth } from "better-auth";
46
+ import { expo } from "@better-auth/expo"; // Import the server plugin
47
+
48
+ export const auth = betterAuth({
49
+ // ...your other Better Auth options
50
+ baseURL: "http://localhost:8081", // The base URL of your application server where the routes are mounted.
51
+ plugins: [expo()], // Add the Expo server plugin
52
+ emailAndPassword: {
53
+ enabled: true,
54
+ },
55
+ // Add other configurations like trustedOrigins
56
+ trustedOrigins: ["myapp://"] // Replace "myapp" with your app's scheme
57
+ });
58
+ ```
59
+
60
+ ### Initialize the Better Auth Client in Expo
61
+
62
+ In your Expo app, initialize the client (e.g., in `lib/auth-client.ts`):
63
+
64
+ ```typescript
65
+ // lib/auth-client.ts
66
+ import { createAuthClient } from "better-auth/react";
67
+ import { expoClient } from "@better-auth/expo/client"; // Import the client plugin
68
+ import * as SecureStore from "expo-secure-store";
69
+
70
+ export const authClient = createAuthClient({
71
+ baseURL: "http://localhost:8081", // Your Better Auth backend URL
72
+ plugins: [
73
+ expoClient({
74
+ scheme: "myapp", // Your app's scheme (defined in app.json)
75
+ storagePrefix: "myapp", // A prefix for storage keys
76
+ storage: SecureStore, // Pass SecureStore for token storage
77
+ })
78
+ ]
79
+ });
80
+
81
+ // You can also export specific methods if you prefer:
82
+ // export const { signIn, signUp, useSession } = authClient;
83
+ ```
84
+ Make sure your app's scheme (e.g., "myapp") is defined in your `app.json`.
85
+
86
+ ## Documentation
87
+
88
+ For more detailed information and advanced configurations, please refer to the documentation:
89
+
90
+ - **Main Better Auth Installation:** [https://www.better-auth.com/docs/installation](https://www.better-auth.com/docs/installation)
91
+ - **Expo Integration Guide:** [https://www.better-auth.com/docs/integrations/expo](https://www.better-auth.com/docs/integrations/expo)
92
+
93
+ ## License
94
+
95
+ MIT
package/package.json CHANGED
@@ -1,9 +1,15 @@
1
1
  {
2
2
  "name": "@better-auth/expo",
3
- "version": "1.2.12",
3
+ "version": "1.3.0-beta.4",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/better-auth/better-auth",
10
+ "directory": "packages/expo"
11
+ },
12
+ "homepage": "https://www.better-auth.com/docs/integrations/expo",
7
13
  "exports": {
8
14
  ".": {
9
15
  "types": "./dist/index.d.ts",
@@ -26,9 +32,14 @@
26
32
  ]
27
33
  }
28
34
  },
29
- "keywords": [],
30
- "author": "",
31
- "license": "ISC",
35
+ "keywords": [
36
+ "auth",
37
+ "expo",
38
+ "react-native",
39
+ "typescript",
40
+ "better-auth"
41
+ ],
42
+ "license": "MIT",
32
43
  "devDependencies": {
33
44
  "@better-fetch/fetch": "^1.1.18",
34
45
  "better-sqlite3": "^11.6.0",
@@ -39,10 +50,10 @@
39
50
  "expo-web-browser": "~14.0.2",
40
51
  "unbuild": "^3.5.0",
41
52
  "vitest": "^1.6.0",
42
- "better-auth": "1.2.12"
53
+ "better-auth": "1.3.0-beta.4"
43
54
  },
44
55
  "peerDependencies": {
45
- "better-auth": "1.2.12"
56
+ "better-auth": "1.3.0-beta.4"
46
57
  },
47
58
  "dependencies": {
48
59
  "@better-fetch/fetch": "^1.1.18",