Env
Declare your settings and secrets once, then read them as typed values in browser and server code.
Deploys on
- Node
- Docker
- Cloudflare
- Vercel
- Netlify
- Deno
nuxt.config.ts
import { env } from 'vite-hub/env'
export default defineNuxtConfig({
modules: ['vite-hub/nuxt'],
vitehub: {
env: {
// Safe to show in the browser
public: {
appName: env({ default: 'Acme' }),
},
// Only server code can read these
server: {
github: {
token: env({
secret: true,
source: env.source('GITHUB_TOKEN'),
}),
},
dryRun: env.boolean({ default: true }),
},
},
},
})Typed values
Read environment strings as a boolean, a number, or one of a list of choices. A wrong value fails with a clear error.
Clear variable names
env.server.github.token reads VITEHUB_GITHUB_TOKEN first, then the name you give in env.source().