Skip to content

Environment Variables

Read environment variables exposed to the sandbox via the run config.

src/index.ts
import type { ExportedHandler } from "kyushu-types";
export default {
async fetch() {
const apiKey = process.env.API_KEY ?? "not set";
return {
status: 200,
headers: { "content-type": "application/json" },
body: JSON.stringify({ API_KEY: apiKey }),
};
},
} satisfies ExportedHandler;

By default, the sandbox has no access to the host environment. Explicitly expose variables to make them available to your worker.

kyushu.toml
[[worker.env]]
key = "API_KEY"
value = "secret"

Try it

Start the development server.

Terminal window
kyu dev kyushu.toml

Then send a request to test it.

Terminal window
curl http://localhost:5987