- [Narrator] One thing is common
when you talk about deployments in Nuxt.
You either deploy a server-rendered app,
or a statically-generated app.
But what does all of this actually mean?
I'll explain.
Nuxt has two deployment strategies;
server hosting and static hosting strategy.
First, the server hosting strategy
is used when you run your application entirely
on a node JS server.
When a user requests a page,
the browser will request that page directly from the server.
Nuxt will handle the request and send the results
and all of its content back to the browser.
You can use this hosting strategy when rendering HTML
on each request to the server rather than add build time.
Or if you want to extend the server with Nuxt middleware.
To configure the server hosting,
you need to register the target option
in your Nuxt config file as server.
And use the build command, MPM run,
build or Nuxt build when you are running it on your server.
Static hosting on the other hand
means that there are no server needed,
and in order to deploy your application,
the application is rendered at build time
and it'll regenerate HTML files for each one of your page
and store them inside the dist directory.
The target option also needs to change.
And for static generated applications,
it needs to change to static, right?
I'll show you an example here.
So if we try to actually build our projects with static,
so in this case, run, MPM, run, generate.
We know that we set our target to static here.
So, what it does is it automatically builds our files
and bonds it into HTML files that we can then deploy
to a static hosting platform.
I'll show you an example.
It also includes a new dist directory here.
Currently, we have just one page.
We have the index of view page.
So here, it's automatically generated HTML files
for that page.
And now, we have an index of HTML page
with the content included.
So, that's the difference between the server hosting
and the static hosting.
Depending on what deployment strategy
your application requires,
you can set up the deployment targets
based on the need of your app.