Replies: 14 comments 13 replies
-
Good news! |
Beta Was this translation helpful? Give feedback.
-
Amazing stuff @leerob! Questions on
Basically, would love to see as many Vercel-specific flags, headers and env vars (eg, Ofc totally get there'll be things y'all want to run as optimized as you can, but if there's a way that can be refactored into the adapter design, that'd be ideal! 🙏 |
Beta Was this translation helpful? Give feedback.
-
wow, didn't think this was possible. one of you guys should tweet: deployment adapters achieved internally. |
Beta Was this translation helpful? Give feedback.
-
Good stuff |
Beta Was this translation helpful? Give feedback.
-
Make sure to allow for HTTP Headers customizability within each of these adapters. For instance, Cloudflare is known to cause issues with |
Beta Was this translation helpful? Give feedback.
-
That's great news. I've got like 3 questions. I'm pretty stoked about this. |
Beta Was this translation helpful? Give feedback.
-
I have a question about the export type RouteHas =
| {
type: string
key: string
value?: string
}
| {
type: 'host'
key?: undefined // Why does this have an optional key of type undefined?
value: string
} This feels kinda weird and I don't get it but I could also be missing something really obvious. |
Beta Was this translation helpful? Give feedback.
-
What's the planned versioning strategy for this API? Will it follow the same semantic versioning as Next.js itself? |
Beta Was this translation helpful? Give feedback.
-
Are we planning to add support to allow both SSG and ISR/SSR at the same time, to be able to get the functionality that some pages could be served from a static HTTP server and some from next server? Reason: We have our custom go lang server which acts as a Static Gateway, Next server or Node server doesnt scale well considering when the 40% of our pages are static. In a distributed system it causes a lot of issue as we cant store tons of pages in memory, secondly EFS is quote costly, then we can store HTML strings directly in cache for obvious reason, then we dont want to waste compute for static pages. So we planned that there must be some sort of way or load balancer which has the capability to HTTP serve static pages and dynamic serve Next pages via its own server. |
Beta Was this translation helpful? Give feedback.
-
So, I hope this initiative will help to friend Docker and Nextjs ENV variables |
Beta Was this translation helpful? Give feedback.
-
Great news! |
Beta Was this translation helpful? Give feedback.
-
Good news 😃 |
Beta Was this translation helpful? Give feedback.
-
This is great news! |
Beta Was this translation helpful? Give feedback.
-
Looking forward to seeing AWS Amplify integration 😎 |
Beta Was this translation helpful? Give feedback.
-
To ensure Next.js can be deployed anywhere, including severless platforms with custom requirements, we are planning to add deployment adapters. Vercel will use the same adapter API as every other partner.
Background
Next.js has supported self-hosting since 2016, including ejecting out of the Next.js server to a fully custom Express server. This includes deployment as a Node.js server (
next start
), standalone output, or a static export.However, it has been difficult for serverless platforms like Netlify to support deploying Next.js due to their custom requirements. After talking with their team and others, we want to make Next.js easier to maintain for deployment platforms.
We also want to ensure Vercel adheres to the exact same adapter pattern, so there is parity between deployment providers for the Next.js output format used.
Pain points
After discussing with various teams from different providers and collecting their feedback, we have identified several pain points in the existing build outputs and our API surfaces.
We aim to address the following issues in this RFC:
No signal for when background work like revalidating is complete
No ability to set or change specific
next.config
values without patching the file directly before a buildnext.config
today, providers have to either wrap their user’snext.config
manually or use internal environment variables that aren’t officially documented (related example).No build interface for receiving configs/entrypoint information without digging through undocumented manifests
No stable interface for executing entrypoints without the full next-server
next-server
must be loaded and relied on. This causes pain from slowing down cold boots and giving less control over the request. Examples of handling that need to be added to leveragenext-server
in different environments can be seen here and here.Proposed changes
Build output changes
To fix the core issue with executing entrypoints, we will remove the need to use
next-server
.All entrypoints, including middleware, will now have a consistent signature that can be used:
Each entrypoint will now expose its signature directly, eliminating the need to load manifests during runtime. This allows each entrypoint to operate independently, loading only its required configuration.
To address concerns about knowing when background tasks are complete, a
waitUntil
callback can be provided. This callback will receive a promise that resolves once Next.js finishes processing tasks such as cache revalidation or executingafter()
callbacks.If
waitUntil
is not provided, the promise returned by the handler method will not resolve until all background work is completed. For the edge runtime, this means theResponse
will not be returned immediately unlesswaitUntil
is used.Adapter API details
To alleviate two of the most significant pain points we've seen across providers—modifying
next.config
values and tracking outputs in the.next
folder—we are implementing the following new adapter API:Below is an example of the context provided to
onBuildComplete
for a minimal project.To configure an adapter, users can install it in their
package.json
and specify it in thenext.config
file using theadapterPath
option.For platforms like Netlify or Vercel that aim to auto-configure the adapter, a default can be set using the
NEXT_ADAPTER_PATH
environment variable. However, any adapter explicitly configured by the user innext.config
will take precedence over the one provided via the environment variable.Configured adapters are only utilized during builds to prevent conflicts in the development environment and simplify adapter implementations. If the need arises, we may explore dev-specific hooks for adapters in the future.
Adoption and rollout
We have created a working group with Netlify, Cloudflare, Amplify, and OpenNext. Together, we are designing and iterating on the API. We will begin by using the Vercel adapter to dogfood the new API.
Once these APIs reach stability, we will provide official documentation to ensure providers can fully understand and utilize them. Additionally, platforms which adhere to the adapter API will be listed in the Next.js deployment documentation.
We want to ensure the community can easily find and contribute to adapters, so we plan on hosting the repositories in the Next.js GitHub organization. We have already published a number of examples for deploying self-hosted Next.js applications here.
Not planned
We do not plan for this Adapters API to be used (or designed) for allowing custom runtimes currently.
For partners and providers
If you would like to collaborate with us on implementing an adapter, you can respond on this thread or reach out to
[email protected]
.Beta Was this translation helpful? Give feedback.
All reactions