Over the last lectures we learned a lot about nextjs,
now there is more to learn about it
I will not doubt that. You can always visit the official github page I showed you a couple of times throughout
this module and you can visit learnnextjs.com, an official page by the creators of nextjs
which requires a github account to log in but which then step by step walks you through the core features.
With that, you should be able to really utilize this together with the react knowledge you gained throughout
this course because you are still building a react application in the end
to build a react that which is server side rendered by default where you don't need to worry about
code splitting and routing and where you therefore might have an easier time creating the react app
you're looking to create.
Let me finish this module by showing you how you actually prepared this for deployment then. Let's quit
our development server and let's revisit the package.json file.
Remember we added three scripts here,
build and start are two other scripts. Build is the script you want to execute to build the project for deployment,
so by simply running npm run build, it will now compile and optimize all that code and spit it out,
ready for you to ship to a server.
Now once npm run build is done, you get the .next folder,
this now contains all the build content.
Now this folder here is what actually needs to be deployed but you would deploy the entire project folder
because you also need to install node modules and so on.
So you would deploy the entire project folder here to a host like AWS elastic beanstalk or Heroku.
And that's important,
you need a host, a service which is able to run nodeJS because nextjs
uses nodejs and only works on nodejs, all the files you deploy are javascript files. So
you need a nodejs
ready host and then you ship your entire project there and just execute npm start, the third
script.
We can also run this locally since we got nodejs installed here.
this will now still serve the app on localhost:3000
but now it's the app we prepared for deployment, it works as before but it's actually using the optimized
files where everything is minified and so on and it shows that everything works and therefore
if you ship the entire project and then execute npm install followed by npm start on your server, you
have your react nextjs application running on a real server with all the benefits nextjs
gives you.
Again if you want to learn more about nextjs,
don't miss the chance of diving into the official docs here on the github repo or on learnnextjs.com
.