Closed adolfusadams closed 4 months ago
Remove your depedency "@supabase/supabase-js", why have you both, this an "@nuxtjs/..."?
For readability I would suggest, you define supabase in your nuxt.config outside like this:
... modules: [ '@nuxtjs/supabase', .... ], supabase: { redirect: false, }, ..
Now to the more important part. Did you configure your runtime environment correctly in your nuxt.config, as well are you using your supabase keys correctly?
Add this to your nuxt.config:
runtimeConfig: { public: { SUPABASE_URL: process.env.SUPABASE_URL, SUPABASE_PUBLIC_KEY: process.env.SUPABASE_KEY, }, SUPABASE_SERVICE_KEY: process.env.SUPABASE_SERVICE_KEY, },
And here my .env file:
SUPABASE_URL= SUPABASE_KEY= SUPABASE_SERVICE_KEY=
Here, the public is the public key, and the service key is the one with "service_rolesecret" which bypasses role security, so choose to your needs, which one you want to use later, only public anon or service key.
Then you should be able to just use: const user = useSupabaseUser();
or const supabase = useSupabaseClient();
without any problems in your components.
Now delete you lockfile and node_modules, install again (just to start clean with npm i or yarn ;)) and you should be good to go.
Thanks @Shooteger for the update. I did exactly as you indicated but the error is still the same.
I'm kinda on the same boat.
The useSupabaseClient()
returns null
so .auth
doesn't work, but the useSupabaseUser()
composable is fine.
I can't tell why, but putting the <script>
block above the <template>
block works for me.
Version
@nuxtjs/supabase: v1.1.5 nuxt: v3.9.0
Description
When I run
npm run dev
I get the following error message on the page in the browser;Below is some additional information.
package.json
nuxt.config.ts
My .env file has the correct Supabase credentials
.env
app.vue
default.vue
I did the following;
The line with
const client = useSupabaseClient()
(in both the app.vue and default.vue pages) is producing the error messageCannot find name 'useSupabaseClient'
in the vs code editor.