Skip to content

Latest commit

 

History

History
35 lines (22 loc) · 1.37 KB

File metadata and controls

35 lines (22 loc) · 1.37 KB

Netlify examples

Use environment variables with Netlify Edge Functions

Netlify Edge Functions support open-source Deno APIs. To access your Netlify environment variables in Edge Functions, use the Deno.env API.

Code example

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" },
  });
};

View this example on the web

Deploy to Netlify

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.

Deploy to Netlify