Netlify Edge Functions support open-source Deno APIs. To access your Netlify environment variables in Edge Functions,
use the Deno.env
API.
Edge Functions are files held in the netlify/edge-functions
directory.
import type { Context } from "https://edge.netlify.com";
export default async (request: Request, context: Context) => {
const value = Deno.env.get("MY_IMPORTANT_VARIABLE");
return new Response(`Value of MY_IMPORTANT_VARIABLE is "${value}".`, {
headers: { "content-type": "text/html" },
});
};
You can deploy this and all the other examples in this repo as a site of your own to explore and experiment with, by clicking this button.