Local Development

Local Development: JavaScript & TypeScript

Run Vite (Vue, React, Svelte), Next.js, Nuxt and Node.js apps locally with secrets from Ennote instead of a .env file, by starting the dev server with ennote secret get.

The pattern is the same for every JavaScript tool: in package.json, put ennote secret get "<secret>" -- in front of the command that starts the dev server. Run npm run dev (or pnpm dev, yarn dev, bun dev) as usual.

The examples use a secret named site-env in a workspace with the ID local-development. Replace my-org-id and the other IDs with your own. See Local development without .env files for the one-time setup.

Vite (Vue, React, Svelte, Solid)

package.json
{
  "scripts": {
    "dev": "ennote secret get \"site-env\" --organization-id \"my-org-id\" --workspace-id \"local-development\" -- vite",
    "build": "vite build"
  }
}

Vite reads variables from the environment it starts in, so keys from Ennote work exactly like keys from a .env file:

  • Keys that start with VITE_ are available in your app code as import.meta.env.VITE_API_URL.
  • All keys are available in vite.config.ts and in server-side code through process.env.
src/api.ts
const apiUrl = import.meta.env.VITE_API_URL
Everything prefixed with VITE_ is compiled into the JavaScript bundle that browsers download, so anyone can read it. Only put public values there, such as API URLs or publishable keys. Keep secret keys (database passwords, private API keys) in your backend.

Next.js

package.json
{
  "scripts": {
    "dev": "ennote secret get \"site-env\" --organization-id \"my-org-id\" --workspace-id \"local-development\" -- next dev"
  }
}
  • Server code (Route Handlers, Server Components, Server Actions) reads any key with process.env.DATABASE_URL.
  • Keys that start with NEXT_PUBLIC_ are inlined into the browser bundle and are public, like VITE_ keys.

Next.js still loads .env* files if they exist, but variables already set in the environment take precedence, so the values from Ennote win.

Nuxt

package.json
{
  "scripts": {
    "dev": "ennote secret get \"site-env\" --organization-id \"my-org-id\" --workspace-id \"local-development\" -- nuxt dev"
  }
}

Name the keys after your runtimeConfig and Nuxt fills it in at start-up. A key NUXT_API_SECRET sets runtimeConfig.apiSecret, and NUXT_PUBLIC_API_BASE sets runtimeConfig.public.apiBase:

nuxt.config.ts
export default defineNuxtConfig({
  runtimeConfig: {
    apiSecret: '', // server only, set by NUXT_API_SECRET
    public: {
      apiBase: '', // exposed to the browser, set by NUXT_PUBLIC_API_BASE
    },
  },
})

Node.js (Express, Fastify, NestJS)

package.json
{
  "scripts": {
    "dev": "ennote secret get \"api-env\" --organization-id \"my-org-id\" --workspace-id \"local-development\" -- node --watch src/server.js"
  }
}

The same works with any runner: -- tsx watch src/server.ts, -- nodemon, -- nest start --watch. Read the values with process.env:

src/server.js
const databaseUrl = process.env.DATABASE_URL

If your code calls dotenv.config() or uses node --env-file, you can keep it while you migrate. Neither overrides variables that are already set, so the values from Ennote win.

Monorepos and Several Apps

Each app can use its own secret. For example, a frontend and an API in one repository:

package.json
{
  "scripts": {
    "dev:web": "ennote secret get \"web-env\" -- pnpm --filter web dev",
    "dev:api": "ennote secret get \"api-env\" -- pnpm --filter api dev"
  }
}

These scripts leave out the IDs and use the organization and workspace set with ennote config set.

FAQ

Do I need ennote in every script?

Only in scripts that need secrets, usually dev, and scripts such as db:migrate or seed. Production builds and deployments get their secrets from your CI/CD pipeline. See GitHub Actions or GitLab CI/CD.

Does the package.json script work on Windows?

Yes. The escaped double quotes (\"site-env\") work in the shells npm uses on Windows, macOS and Linux.

Why is my VITE_ variable undefined in the browser?

Check that the key name in Ennote starts with VITE_ exactly, and restart the dev server after changing the secret. Values are read when the command starts.

Need Help?

If you encounter any issues or have questions, don't hesitate to contact support. Our team is here to assist you with any challenges you might face.