npm install @edusperoni/nativescript-supabaseThis plugin makes @supabase/supabase-js work in NativeScript.
It does two things for you:
- Adds NativeScript-compatible build replacements through
nativescript.webpack.js. - Polyfills browser APIs needed by Supabase when you import the plugin:
localStorage(backed by NativeScriptApplicationSettings)WebSocket(via@valor/nativescript-websockets)
After that, just use the official Supabase JS client.
npm install @edusperoni/nativescript-supabase @supabase/supabase-jsImport this package before creating your Supabase client.
import '@edusperoni/nativescript-supabase';Place it in your app entry file (for example, app.ts / main.ts) so it runs once on startup.
import '@edusperoni/nativescript-supabase';
import { createClient } from '@supabase/supabase-js';
const supabaseUrl = 'https://YOUR_PROJECT_ID.supabase.co';
const supabaseAnonKey = 'YOUR_SUPABASE_ANON_KEY';
export const supabase = createClient(supabaseUrl, supabaseAnonKey);
async function loadProfile() {
const { data, error } = await supabase.from('profiles').select('*').limit(1);
if (error) {
console.error(error);
return;
}
console.log(data);
}- No extra manual polyfill setup is required beyond importing
@edusperoni/nativescript-supabase. localStoragepersistence maps to NativeScript app settings storage.- Supabase usage (auth, realtime, queries, storage client APIs) follows the standard
@supabase/supabase-jsdocumentation.
Apache License Version 2.0