kit icon indicating copy to clipboard operation
kit copied to clipboard

Configure deployment as Vercel edge functions on a per-endpoint basis

Open mquandalle opened this issue 2 years ago • 2 comments

Describe the problem

In Next.js it is possible to deploy an endpoint as a Vercel edge function. Contrary to the global edge: boolean option of SvelteKit adapter-vercel, it is possible to choose the runtime (lambda or edge) on a per endpoint basis.

Describe the proposed solution

In +page.js export something similar to

export const config = {
  runtime: 'experimental-edge',
};

Alternatives considered

No response

Importance

would make my life easier

Additional Information

I have an application where I need this because some of my routes cannot be deployed to the edge (they use native NodeJs dependencies), and some of my routes need the ability to finish some async work after a response is returned (which is not possible in lambdas).

My current workaround is to amend the build output of SvelteKit by creating a .vercel/output/myedgefunc.func directory that follows the Vercel build output API. It works, but is complicated and fragile. It would make my life easier if this was supported by the framework.

mquandalle avatar Sep 14 '22 13:09 mquandalle

This is definitely something we want to do post-1.0. The challenge is designing it in a sufficiently future-proof and framework-agnostic way (e.g. it would make sense to use the same approach for Netlify)

Rich-Harris avatar Sep 14 '22 22:09 Rich-Harris

Would it make sense to be able to export it like export const edge = true; from page.ts and use it in the adapter?

enyo avatar Dec 08 '22 21:12 enyo

Closing in favour of #8383

Rich-Harris avatar Jan 17 '23 16:01 Rich-Harris