#Disable edge runtime

1 messages · Page 1 of 1 (latest)

valid tree
#

Can I use the nodejs runtime instead of edge?

split portalBOT
#

Hi @valid tree. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Yes, you can use the Node.js runtime instead of the Edge runtime in your Next.js application. By default, if the runtime is not specified, the Node.js runtime will be used.

To explicitly set the runtime to Node.js, you can declare a variable called runtime and export it. The variable must be a string, and must have a value of either 'nodejs' or 'edge' runtime. Here's how you can do it:

export const runtime = 'nodejs' // 'edge' | 'nodejs'

You can specify this in individual route segments or on a layout level, which will make all routes under the layout run on the specified runtime.

Please note that using the Node.js runtime gives you access to all Node.js APIs, and all npm packages that rely on them. However, it's not as fast to start up as routes using the Edge runtime. Also, deploying your Next.js application to a Node.js server will require managing, scaling, and configuring your infrastructure.

For more information, you can refer to the Next.js documentation on Edge and Node.js runtimes (https://nextjs.org/docs/app/building-your-application/rendering/edge-and-nodejs-runtimes).

Please note that Middleware only supports the Edge runtime. The Node.js runtime cannot be used for Middleware.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: