forked from netlify/edge-functions-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (26 loc) · 1.13 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import repoLink from "../../components/repo-link.js";
export default {
title: "Environment variables",
metaDescription: "Learn how to use environment variables in Netlify Edge Functions.",
page: function () {
return `
<section>
<h1>Use environment variables</h1>
<p>Netlify Edge Functions support open-source Deno APIs. To access your Netlify environment variables in Edge Functions, use the <code>Deno.env</code> API.</p>
<pre><code>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" },
});
};</code></pre>
<h2>See this in action</h2>
<ul>
<li><a href="/environment">View the response from the Edge Function</a></li>
<li><a href="https://doc.deno.land/deno/stable/~/Deno.env" target="_blank" rel="noopener">View the Deno.env API docs</a></li>
<li>${repoLink("environment.ts")}</li>
</ul>
</section>
`;
},
};