Skip to content

Commit 43b93fe

Browse files
committed
docs: update README with usage instructions for nativescript-supabase
1 parent 368b207 commit 43b93fe

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

packages/nativescript-supabase/README.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,59 @@ npm install @edusperoni/nativescript-supabase
66

77
## Usage
88

9-
// TODO
9+
This plugin makes `@supabase/supabase-js` work in NativeScript.
10+
11+
It does two things for you:
12+
13+
- Adds NativeScript-compatible build replacements through `nativescript.webpack.js`.
14+
- Polyfills browser APIs needed by Supabase when you import the plugin:
15+
- `localStorage` (backed by NativeScript `ApplicationSettings`)
16+
- `WebSocket` (via `@valor/nativescript-websockets`)
17+
18+
After that, just use the official Supabase JS client.
19+
20+
### 1) Install
21+
22+
```bash
23+
npm install @edusperoni/nativescript-supabase @supabase/supabase-js
24+
```
25+
26+
### 2) Import once at app startup
27+
28+
Import this package **before** creating your Supabase client.
29+
30+
```ts
31+
import '@edusperoni/nativescript-supabase';
32+
```
33+
34+
Place it in your app entry file (for example, `app.ts` / `main.ts`) so it runs once on startup.
35+
36+
### 3) Use Supabase normally
37+
38+
```ts
39+
import '@edusperoni/nativescript-supabase';
40+
import { createClient } from '@supabase/supabase-js';
41+
42+
const supabaseUrl = 'https://YOUR_PROJECT_ID.supabase.co';
43+
const supabaseAnonKey = 'YOUR_SUPABASE_ANON_KEY';
44+
45+
export const supabase = createClient(supabaseUrl, supabaseAnonKey);
46+
47+
async function loadProfile() {
48+
const { data, error } = await supabase.from('profiles').select('*').limit(1);
49+
if (error) {
50+
console.error(error);
51+
return;
52+
}
53+
console.log(data);
54+
}
55+
```
56+
57+
## Notes
58+
59+
- No extra manual polyfill setup is required beyond importing `@edusperoni/nativescript-supabase`.
60+
- `localStorage` persistence maps to NativeScript app settings storage.
61+
- Supabase usage (auth, realtime, queries, storage client APIs) follows the standard `@supabase/supabase-js` documentation.
1062

1163
## License
1264

0 commit comments

Comments
 (0)