Search code examples
react-nativeexposupabase

Why am I getting "URL.hostname is not implemented, js engine hermes" when supabase is intialized?


I am building an expo project. So far I'm just trying to create the login/sign up auth logic. I want to use supabase. The project will load if there is no supabase initialization, but when supabase.js is not all commented out, I get the following error:

ERROR Error: URL.hostname is not implemented, js engine: hermes

The supabase initialization is as follows:

import {createClient} from "@supabase/supabase-js";

const supabaseUrl = "...";
const supabaseKey = "...";

export const supabase = createClient(supabaseUrl, supabaseKey);

Everything is installed correctly and I am using the latest versions of Supabase, expo, etc.


Solution

  • There's an issue with RN and Supabase but there is a workaround until a fix can be implemented just add react-native-url-polyfill to your project and it should clear the error.

    yarn add react-native-url-polyfill
    

    Then import the package where the client is initialized:

    import 'react-native-url-polyfill/auto'
    
    import { createClient } from '@supabase/supabase-js'
    

    Refer to the following issue for more information: https://github.com/supabase/supabase/issues/8464#issuecomment-1221448428