13 Replies
Prefix the variables with
VITE_
and access them via import.meta.env
ty
this won't work when trying to change them at runtime, just FYI
I'd suggest passing the runtimeConfig part in there when using the JS file
.env
<NUXT_SOME_NAME>=someValue
nuxt.config.ts
runtimeConfig: { public: { <someName>: import.meta.env.NUXT_SOME_NAME}}
and then in your code use
some.vue
const config = useRuntimeConfig();
const theThing = config.public.<someName>
if you don't want them public, put the env value top level of "runtimeConfig" (e.g. outside of public)You can even leave the right hand side of the runtimeConfig value empty
Alexander Lichter
YouTube
Nuxt's runtimeConfig - The most common mistake
🤯 Throughout my projects, consultancies and code reviews I came across lots of interesting findings - also with regards to Nuxt's runtimeConfig feature. Repeatedly I noticed ONE big mistake though which you might do at this very moment in your project. In this video, explain what it is, why you shouldn't do it and how to use runtimeConfig correc...
are u telling me to do this?
this is the only way?
I'd just pass the two values to the function
but besides that, yes.
You might be easier off using https://github.com/nuxt-modules/supabase though
GitHub
GitHub - nuxt-modules/supabase: Supabase module for Nuxt.
Supabase module for Nuxt. Contribute to nuxt-modules/supabase development by creating an account on GitHub.
whats that?