Import .env into app{ head{ script{
Im loading a analytics script inside my nuxt.config.ts and want to dynamically change the key via an env var, but the scope doesnt have acess to process or useRUntimeConig, any thoughts:
7 Replies
Bump here, any chance I can get some help with this?
hey, you should probably use a plugin with useHead
or
app.vue with use head
@harlan can you point me in the right direction on where i can see how to make this into a plugin?
sure, just make a file
plugins/analytics.client.ts
Nuxt
plugins/ · Nuxt Directory Structure
Nuxt reads the files in your plugins directory and loads them at the creation of the Vue application.
@harlan thank you, do i have access to the
useHead({
script: [
durectly inside of that file or do i need to wrap that in something else
import { useHead } from '#imports'
if it's not auto-imported