Skip to content

Latest commit

 

History

History
57 lines (39 loc) · 1.95 KB

File metadata and controls

57 lines (39 loc) · 1.95 KB

Learn Next.js

05. Where to go from here

Full deploy

The last step here would be to deploy the application. With Vercel it's just a matter of running:

$ vercel
-- or --
$ vercel --prod

and in a matter of seconds we will have all of our code running on a public accessible url.

On different platforms things may be slightly different, and if your not using a CI/CD integrations you will definetely need to run

$ npm run build

locally before deploying. But remember that to deploy a SSR application we need a server running Node.js, more details can be found in the docs.

Static deploy

If you want to deploy a SSG solution, like the blog generated from API that we created in the first guide, you will have to run two commands:

$ npm run build
$ npx next export

the export command is the one responsible of generating the .html & co files so if you plan to run it often a nice idea may be to take advantage of the package.json's scripts:

{
  ...
  "build:static": "next build",
  "postbuildbuild:static": "next export",
  ...
}

so by running a single command you will get the second script running subsequentially

$ npm run build:static

at this point you will have an /out folder containing the static build that can be deployed in whatever hosting powered by a webserver that you prefer, most notable Github Pages which comes for free with every public repo. If you choose this option you may also want to add a simple GH Actions file to automatically build and publish a static website at each commit on your repository.

Next(js) steps