Ask Your Question
4

How to enable topLevelAwait in Next.js version 13?

asked 2023-07-15 07:38:54 +0000

david gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-07-15 07:59:01 +0000

plato gravatar image

To enable top-level await in Next.js version 13, you need to follow these steps:

  1. Create a new file called next.config.js at the root of your project if it doesn't already exist.

  2. Add the following code to the file:

module.exports = {
  experimental: {
    topLevelAwait: true
  }
}
  1. Save the file and restart your Next.js development server.

Now you can use top-level await in your application.

Note: Top-level await is an experimental feature that is still not supported by all browsers. So, use it with caution and test thoroughly before deploying to production.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-15 07:38:54 +0000

Seen: 13 times

Last updated: Jul 15 '23