I'm starting my react-native project using expo in the iOS version and getting this obscure error which is blocking development progress. I've only started to see this error after trying to setup the supabase.js package and trying to setup the library against my supabase instance running locally via the supabase-cli.
I'm also polyfilling the URL package using react-native-url-polyfill/auto
. If I do not polyfill the URL library, I see another error on startup that says Unhandled JS Exception: Can't find variable: URL
. You can see even supabase provides it in their own documentation.
I'm at my wits end and would like some direction on how to move forward so that I can continue building my application.
Below is a sample of the typescript file that's triggering this error:
import { createClient } from "@supabase/supabase-js";
import {Database} from "../../lib/supabase/database.types";
import 'react-native-url-polyfill/auto'
interface CreateUserOpts {
name: string;
username: string;
phone: string;
password: string;
}
const supabaseUrl = "http://localhost:54321";
const supabaseAnonKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0";
const client = createClient<Database>(
supabaseUrl,
supabaseAnonKey,
{
auth: {
detectSessionInUrl: false
}
}
)
export const createUser = async (opts: CreateUserOpts) => {
const {phone, password, ...additionalOpts} = opts;
return client.auth.signUp({
password: password,
phone: phone,
options: {
data: {
...additionalOpts
}
}
})
}