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:
API_KEY=sk-123456const response = await fetch('https://api.example.com/items', {
headers: { Authorization: `Bearer ${process.env.API_KEY}` },
});.envuses the same format as the Node.js--env-fileoption. As in Node.js, variables that OneScript already provides (HOME,TMPDIR,USER,PATH,LANG) take precedence, so they can't be set in.env..envis 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