0

How can I resolve the "The top-level-await experiment is not enabled" error that occurs when adding MongoDB in the [...nextauth] file of my open-source project, Electronic Patient Records? Here are the relevant links:

Project URL: https://epr-erwinagpasa.vercel.app

GitHub Repository: https://github.com/erwinagpasa/epr

enter image description here

1
  • 1
    Have you tried putting the "topLevelAwait: true" after line 4 of the next.config.js file? Commented May 21, 2023 at 16:00

1 Answer 1

1

What did the trick on my codebase is including in the next.config.js

    /** @type {import('next').NextConfig} */
    const nextConfig = {
    reactStrictMode: true,
    experimental: { appDir: true },
    webpack(config) {
        config.experiments = { ...config.experiments, topLevelAwait: true }
        return config
    },
}

module.exports = nextConfig
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.