Using edge functions as an endpoint?

Similar to serverless functions and other endpoints, an edge function can just return a standard Response object.

That’s what the docs say here.

Is it possible to call edge functions from within the client react app? How would I go about doing it? All examples I’ve seen, use edge functions as a middleware for redirects or rewrites, but I’d expect it to work as an endpoint too. Could you show me an example?

I may also have a misconception of how these are used. My objective is to serve localized content by using edge functions, while not having to change the logic of the app to using them as a middleware instead of an endpoint.

Please let me know if my issue is not clear. Thank you very much in advance!

Yes, it’s possible.

Edge Function:

import type {Config} from '@netlify/edge-functions'
export default async function() {
  return Response.json({
    msg: 'hello world'
export const config : Config = {
  path = "/api/hello"

Front end:

fetch('/api/hello').then(res => res.json()).then(data => {
  console.log(data.msg) // 'hello world'