OneScript

Environment Variables

Project environment variables injected into process.env.

Add environment variables for a project in More Settings › Environment Variables, opened from the project's title menu. They are saved to .env in the project root and added to process.env every time the project runs:

.env
API_KEY=sk-123456
const response = await fetch('https://api.example.com/items', {
  headers: { Authorization: `Bearer ${process.env.API_KEY}` },
});
  • .env uses the same format as the Node.js --env-file option. As in Node.js, variables that OneScript already provides (HOME, TMPDIR, USER, PATH, LANG) take precedence, so they can't be set in .env.
  • .env is not included when you share a project as a file or a link. It is stored with the project, so it syncs to iCloud Drive when iCloud sync is on.

How is this guide?

Last updated on