kit
kit copied to clipboard
Configure deployment as Vercel edge functions on a per-endpoint basis
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.
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)
Would it make sense to be able to export it like export const edge = true;
from page.ts
and use it in the adapter?
Closing in favour of #8383