MDB CLI Next.js configuration

MDB CLI Next.js configuration

Next.js configuration


Next.js static project  

 Initialize

In order to initialize empty project use the following command:

Please change also build directory to `dist` in next.config.js or use -o flag in export command

So, the scripts section in package.json should look like this:

        
            
                "scripts": {
                  "dev": "next dev",
                  "build": "next build & next export -o dist/",
                  "start": "next start"
                }
                
        
    

 Publish

Once you finish building your project, use the following command to deploy it:


If you are publishing for the first time, CLI will ask you few initial questions like

  • Whether you want to use npm or yarn?
  • What is your project name, version, description, github address and license

Once you successfully publish your project they will be stored for a future.

Note: Since frontend is a default value for publish command, you can run just mdb publish (instead of mdb frontend publish )

Remember: Project build must be exported to dist directory. Default directory for Next.js is out and if you leave it, you project wouldn't work!


Next.js server-side project  

 Initialize

In order to initialize empty project use the following command:

  You can also skip this step and initiate your Next.js app first. You will be asked to provide necessary information on publishing project later.

 Publish

Next using Node.js to handle server-side rendering, that's why we need to publish project with node

Once you finish building your project, use the following command to deploy it:


If you are publishing for the first time, CLI will ask you few initial questions like

  • Whether you want to use npm or yarn?
  • What is your project name, version, description, github address and license

Once you successfully publish your project they will be stored for a future.

Remember: Project port must be set to 3000

Video tutorial: