Great, you have your Next.js app correctly working on your local machine. You now want to quickly deploy it online to share it with your friends or team. There are several CI/CD services that allow you to publish your static website for free by simply connecting to the Github repository where your project stands:
Let's focus on Netlify from here.
Edit your package.json for production
If you created your Next.js app using the npx create-next-app
command, your scripts object in package.json file should look like this:
"scripts": {
"dev": "next dev",
"build": "next build ",
"start": "next start"
},
Modify it this way :
"scripts": {
"dev": "next dev",
"build": "next build && next export",
"start": "next start"
},
Now, when we create a production build with npm run build
, it will export build files to the out directory.
Setting up your Netlify account
This is the easiest part:
- Create your account here
- Click on New Site from Git
- Follow the linking workflow to connect your Github/Gitlab repo (the one with your Next.js app)
- Make sure you set Deploy Settings like this :
- Click deploy, wait a few seconds and boom, your app is live.
- Optional: Connect a custom domain by editing the DNS A record of your domain
From now on, every time you push a new commit to your Git repository, Netlify will automatically be informed to fetch updates and will then rebuild your Next.js project.
Enjoy & Best!
Top comments (2)
If your project uses Next. js, Netlify automatically installs the Essential Next. js build plugin and provides suggested configuration values. For existing sites already linked to Netlify, you can choose to install the plugin sohbetsayfam.com/ yourself. on average, across our platform, builds take about two minutes. Of course how close you are to this average will be determined by the activity you trigger during your build process.
found this article on google, it helped me a lot! thanks