1 | initial version |
To enable top-level await in Next.js version 13, you need to follow these steps:
Create a new file called next.config.js
at the root of your project if it doesn't already exist.
Add the following code to the file:
module.exports = {
experimental: {
topLevelAwait: true
}
}
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.