Netlify Edge Functions support open-source Deno APIs. To access your Netlify environment variables in Edge Functions,
use the Netlify.env
API.
Edge Functions are files held in the netlify/edge-functions
directory.
import type { Context } from "@netlify/edge-functions";
export default async (request: Request, context: Context) => {
const value = Netlify.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.