In this section we'll look at
how we can deploy our Next.js app to production.
And there are a few ways we can do that.
One factor to consider is
if we need all the Next.js features,
or if we can export our Next.js app
as a static website.
All the Next.js features we used so far
are compatible with exporting our website statically,
so for our Blog application
all the options are available to us.
But if we use some of the more advanced features
that we'll cover in the second part of the course,
things like API routes
or Incremental Static Regeneration,
then we cannot create a statically exported website,
we'll need to run it as a fully-featured Next.js app.
In any case, the simplest way
to run our application in production
is to deploy it to a platform
that supports Next.js out of the box.
Vercel is the company that develops
the Next.js framework,
and it offers a serverless platform
where we can easily deploy our projects.
It's not the only platform that does that,
Netlify also supports Next.js deployments.
Now, if we want to run our application
on our own servers we can also do that.
In fact, we've already seen how that works locally
when we ran our Blog in production mode
with the "next start" command.
All we need is basically a server
with Node.js installed.
This could be a server running in the cloud,
like in Amazon EC2, Google Cloud,
or any other cloud computing provider,
or it could even be on hardware that
we keep on premise.
Even though it's usually more convenient
to rent some servers in the cloud these days.
Either way, the downside of running
your own Next.js servers
is that you need to set up the machines,
maintain them, keep them up to date,
think about how to scale if your traffic grows,
and so on.
While a platform like Vercel
is a fully managed service.
So these options are available
for all Next.js applications.
But, as I mentioned, if we don't use any
of the more advanced Next.js features
we can also export our application
as a static website.
And this means we can deploy it
to pretty much any hosting platform.
We can upload it anywhere
that can host static websites,
like Firebase Hosting, Amazon S3,
or any of the dozens of other
hosting solutions available out there.
Or, again, we could run it on our servers,
but in this case, since it's a static website,
we don't need a server with Node.js,
we can run any standard web server,
like Nginx or Caddy,
or some other open source software.
Now, in the rest of this section
I'll show you an example for each one of
the four main options we have available.
We'll start by deploying to Vercel,
which as I mentioned is the simplest solution.
It's fully managed and supports all Next.js features.
Then we'll see how to statically export our website
and host it on Netlify,
just as an example of the many possible
static hosting solutions.
Then I'll show you one way to run your own web server
by installing Nginx on a virtual machine
running in Digital Ocean.
And finally we'll see how to set up
our own Next.js server,
which I left as last
because it's also the most difficult one,
but I'll show you how to install Node.js
and run our Next.js application,
again using a Digital Ocean server.
Be aware that running your own servers requires
some knowledge of system administration,
so unless you have specific reasons
to do otherwise,
I strongly recommend choosing
a hosted solution like Vercel,
that in fact we'll cover in the next video.