Next.js Discord

Discord Forum

Runtime Questions

Answered
Dandie Dinmont Terrier posted this in #help-forum
Open in Discord
Dandie Dinmont TerrierOP
I'm having some difficulties understanding how Next.js works "under the hood" on Vercel.

- It seems like we can choose whether to render pages and route handlers on the Node.js runtime, or the Edge runtime. Is the Node.js runtime long-running, or does it get "booted up" on each dynamic request?
- According to the docs, server actions use the same runtime as the page they're called from. Is the runtime from when the page loaded still active, or will a new runtime get booted up?
- When I revalidate a tag, the page gets updated live for a user. Does that require spinning up a new runtime?
Answered by Clown
NextJS uses the Node Runtime by default.

You can choose to switch between Edge and Node runtime if you wish and doing so would create a Edge Function or a Serverless Function respectively.

Edge runtime is more cost effective and lighter but exposes only a small subset of the APIs that node runtime provides.
View full answer

3 Replies

NextJS uses the Node Runtime by default.

You can choose to switch between Edge and Node runtime if you wish and doing so would create a Edge Function or a Serverless Function respectively.

Edge runtime is more cost effective and lighter but exposes only a small subset of the APIs that node runtime provides.
Answer
Also im not sure how Vercel handles its runtimes but basically the functions themselves will run and then stop.

When they need to be used again they need to be booted up again(cold start) which takes time. This time depends on what runtime you are using. NodeJS runtime takes time and edge being lighter starts up quicker.
Basically yes if im correct.

Take a look at this too and details regarding AWS Lambda to know more;

https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtime-environment.html#runtimes-lifecycle