What is The Edge? | Edge Functions on Netlify

preview_player
Показать описание
Netlify Functions are now in public Beta! But what is The Edge? And how do Edge functions work?

Edge Functions are very much like serverless functions. You can write them using JavaScript or TypeScript, but instead of using NodeJS under the hood they use Deno — an open source runtime, which works out-of-the-box with web frameworks that support these capabilities.

When you run an Edge Function, it receives two arguments:

• A standard Request object representing the incoming HTTP request
• A Netlify-specific Context object which comes with a LOT of useful functionality

The return value from an Edge Function is either:

• a standard Response object representing the HTTP response to be delivered to the client
• undefined (if you choose to bypass the current function)

To add an Edge Function to your project hosted on Netlify:

• create an edge-functions directory at the root of your project
• add a JS or TS file into that directory

Edge Functions run on the network edge — the server node that's closest to the location of the request, meaning your users get a fast experience, wherever they are.

You can transform requests/responses, stream server rendered content, and even run full applications at The Edge!

0:00 What is The Edge?
01:35 Edge Functions on Netlify
03:35 More Context methods
03:48 Proxy requests using fetch
04:00 Transformations
04:26 Implications for real world applications
04:52 Example site walkthrough
06:13 Deploying the example site to Netlify
Рекомендации по теме