Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.