GitHub 37
Skip to content
ViteHub is still experimental. Expect bugs and breaking changes.

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 }),
      },
    },
  },
})
nuxt.config.ts

Browser or server

Public values can appear in the browser. Server values stay in server code.

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.

Secrets stay hidden

Secrets print as hidden text until you call unseal().

Clear variable names

env.server.github.token reads VITEHUB_GITHUB_TOKEN first, then the name you give in env.source().

Load secrets from your own store

Read values from an outside secret store. Each loadServerEnv() call reads them again.

Change a secret without a redeploy

An admin replaces a stored value while the app runs.