@edge-base/react-native 0.1.1
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.
- package/README.md +230 -0
- package/dist/index.cjs +3137 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1246 -0
- package/dist/index.d.ts +1246 -0
- package/dist/index.js +3118 -0
- package/dist/index.js.map +1 -0
- package/llms.txt +124 -0
- package/package.json +60 -0
package/llms.txt
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# EdgeBase React Native SDK
|
|
2
|
+
|
|
3
|
+
Use this file as a quick-reference contract for AI coding assistants working with `@edge-base/react-native`.
|
|
4
|
+
|
|
5
|
+
## Package Boundary
|
|
6
|
+
|
|
7
|
+
Use `@edge-base/react-native` for React Native apps on iOS, Android, and React Native Web.
|
|
8
|
+
|
|
9
|
+
Do not assume browser-only APIs like `localStorage`, `window.location`, or DOM-based captcha widgets. For browser apps use `@edge-base/web`.
|
|
10
|
+
|
|
11
|
+
## Source Of Truth
|
|
12
|
+
|
|
13
|
+
- Package README: https://github.com/edge-base/edgebase/blob/main/packages/sdk/react-native/README.md
|
|
14
|
+
- Quickstart: https://edgebase.fun/docs/getting-started/quickstart
|
|
15
|
+
- Authentication: https://edgebase.fun/docs/authentication
|
|
16
|
+
- Database client SDK: https://edgebase.fun/docs/database/client-sdk
|
|
17
|
+
- Room client SDK: https://edgebase.fun/docs/room/client-sdk
|
|
18
|
+
- Push client SDK: https://edgebase.fun/docs/push/client-sdk
|
|
19
|
+
|
|
20
|
+
## Canonical Examples
|
|
21
|
+
|
|
22
|
+
### Create a client
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { createClient } from '@edge-base/react-native';
|
|
26
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
27
|
+
import { AppState, Linking } from 'react-native';
|
|
28
|
+
|
|
29
|
+
const client = createClient('https://your-project.edgebase.fun', {
|
|
30
|
+
storage: AsyncStorage,
|
|
31
|
+
linking: Linking,
|
|
32
|
+
appState: AppState,
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Sign in and query data
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
await client.auth.signIn({
|
|
40
|
+
email: 'june@example.com',
|
|
41
|
+
password: 'pass1234',
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const posts = await client
|
|
45
|
+
.db('app')
|
|
46
|
+
.table('posts')
|
|
47
|
+
.where('published', '==', true)
|
|
48
|
+
.getList();
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### OAuth with deep links
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
client.auth.signInWithOAuth('google', {
|
|
55
|
+
redirectUrl: 'myapp://auth/callback',
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
Linking.addEventListener('url', async ({ url }) => {
|
|
59
|
+
await client.auth.handleOAuthCallback(url);
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Register push notifications
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
client.push.setTokenProvider(async () => ({
|
|
67
|
+
token: await messaging().getToken(),
|
|
68
|
+
platform: 'ios',
|
|
69
|
+
}));
|
|
70
|
+
|
|
71
|
+
await client.push.register();
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Turnstile
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
import { WebView } from 'react-native-webview';
|
|
78
|
+
import { TurnstileWebView, useTurnstile } from '@edge-base/react-native';
|
|
79
|
+
|
|
80
|
+
const captcha = useTurnstile({
|
|
81
|
+
baseUrl: 'https://your-project.edgebase.fun',
|
|
82
|
+
action: 'signup',
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
<TurnstileWebView
|
|
86
|
+
siteKey={captcha.siteKey!}
|
|
87
|
+
WebViewComponent={WebView}
|
|
88
|
+
onToken={captcha.onToken}
|
|
89
|
+
/>;
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Hard Rules
|
|
93
|
+
|
|
94
|
+
- `createClient(url, options)` requires `options.storage`
|
|
95
|
+
- `options.linking` is needed for OAuth deep-link flows
|
|
96
|
+
- `options.appState` is optional, but recommended for lifecycle handling
|
|
97
|
+
- `client.db(namespace, instanceId?)` takes the instance id positionally
|
|
98
|
+
- `client.auth.signInWithOAuth()` returns `{ url }` and can open the URL through the provided Linking adapter
|
|
99
|
+
- `client.auth.handleOAuthCallback(url)` resolves the auth result from the callback URL
|
|
100
|
+
- `client.push.setTokenProvider()` must be called before `client.push.register()`
|
|
101
|
+
- `client.push.onMessage()` and `client.push.onMessageOpenedApp()` return unsubscribe functions
|
|
102
|
+
- `TurnstileWebView` requires an injected `WebViewComponent`
|
|
103
|
+
|
|
104
|
+
## Common Mistakes
|
|
105
|
+
|
|
106
|
+
- do not omit `storage`; it is required
|
|
107
|
+
- do not assume browser redirects for OAuth; React Native uses deep links
|
|
108
|
+
- do not call `push.register()` before configuring a token provider
|
|
109
|
+
- do not assume `react-native-webview` is available unless you install it
|
|
110
|
+
- do not assume `app` or `shared` are reserved namespace names; they are examples from project config
|
|
111
|
+
- if you need browser-only code, use `@edge-base/web` instead
|
|
112
|
+
|
|
113
|
+
## Quick Reference
|
|
114
|
+
|
|
115
|
+
```text
|
|
116
|
+
createClient(url, { storage, linking?, appState?, databaseLive?, schema? }) -> ClientEdgeBase
|
|
117
|
+
client.db(namespace, id?) -> DbRef
|
|
118
|
+
client.room(namespace, roomId, options?) -> RoomClient
|
|
119
|
+
client.setLocale(locale) -> void
|
|
120
|
+
client.getLocale() -> string | undefined
|
|
121
|
+
client.push.setTokenProvider(provider) -> void
|
|
122
|
+
client.push.register(options?) -> Promise<void>
|
|
123
|
+
client.destroy() -> void
|
|
124
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@edge-base/react-native",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "EdgeBase React Native SDK — iOS, Android, Web support",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/edge-base/edgebase.git",
|
|
9
|
+
"directory": "packages/sdk/react-native"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://edgebase.fun",
|
|
12
|
+
"bugs": "https://github.com/edge-base/edgebase/issues",
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "./dist/index.cjs",
|
|
18
|
+
"module": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"import": "./dist/index.js",
|
|
24
|
+
"require": "./dist/index.cjs"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"llms.txt"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsup",
|
|
33
|
+
"test": "vitest run",
|
|
34
|
+
"test:e2e": "vitest run --config vitest.e2e.config.ts",
|
|
35
|
+
"test:watch": "vitest",
|
|
36
|
+
"type-check": "tsc --noEmit",
|
|
37
|
+
"prepack": "pnpm run build"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@edge-base/core": "workspace:*"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"react": ">=18.0.0",
|
|
44
|
+
"react-native": ">=0.73.0",
|
|
45
|
+
"@react-native-async-storage/async-storage": ">=1.21.0",
|
|
46
|
+
"react-native-webview": ">=13.0.0"
|
|
47
|
+
},
|
|
48
|
+
"peerDependenciesMeta": {
|
|
49
|
+
"react-native-webview": {
|
|
50
|
+
"optional": true
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/react": "^19.2.2",
|
|
55
|
+
"@types/react-native": "^0.73.0",
|
|
56
|
+
"tsup": "^8.0.0",
|
|
57
|
+
"typescript": "^5.4.0",
|
|
58
|
+
"vitest": "^1.6.0"
|
|
59
|
+
}
|
|
60
|
+
}
|