Next.js Discord

Discord Forum

I'm wondering how I can set the default runtime for my project.

Unanswered
Masai Lion posted this in #help-forum
Open in Discord
Masai LionOP
Hi, Next.js developers! Is there a way to set the default runtime for the whole project without adding
export const runtime = 'edge'
to each file? Thanks!

11 Replies

European sprat
what happens if you set it in the root layout?
looks like that works even for route handlers
@European sprat looks like that works even for route handlers
Masai LionOP
Did you test it? This can be a solution. Thank you for helping me!

I was searching for next.config on the website's documentation but I didn't find this specific config on the current version in the official docs.

I found this code but it was on another website, so I was wondering if is it an outdated approach or not:

experimental: {
    runtime: 'experimental-edge',
  },


Thanks again!
Masai LionOP
I am experiencing some difficulties while starting a project at this moment and I plan to test it when the issues get resolved. thanks
@European sprat I thought there was something in next config too but couldn't find it
it used to be there, but has been removed
Masai LionOP
I have pasted the code in the root layout @European sprat mentioned earlier but It does not work for me. the page is 404 when I am pasting this code. so maybe you @joulev know how to set config for all routes to be 'edge' without specifying in each file? thanks
Masai LionOP
Thanks!