Deploying a Next.js application on Now
Learn how to easily deploy your Next.js application using the Now platform
Note: This tutorial may be outdated as Zeit is now called Vercel
Are you wondering how to deploy your Next.js application so that other people can access it? One simple method is to use the Now platform created by Zeit, the company behind the Open Source project Next.js. Now allows you to deploy Node.js apps, Static Websites, and more.
With Now, the deployment and distribution process becomes simple and fast. In addition to Node.js apps, Now also supports deploying applications written in Go, PHP, Python, and other languages.
Think of Now as a “cloud” where your app will be deployed to a URL that you can easily access.
Getting started with Now is free, as they offer a generous free plan. This plan includes 100GB of hosting, 1000 serverless functions invocations per day, 1000 builds per month, 100GB of bandwidth per month, and one CDN location. If you require more resources, you can refer to the pricing page for more information.
Installation
To start using Now, install the official Now CLI by running the following command:
1 | npm install -g now |
Once the installation is complete, use the following command to login:
1 | now login |
You will be prompted to enter your email. If you haven’t already, create an account on https://zeit.co/signup and then add your email to the CLI client.
After completing these steps, navigate to the root folder of your Next.js project and run:
1 | now |
Now will deploy your application to the Now cloud, and you will be provided with a unique app URL.
When you run the now
command, your app will be deployed to a random URL under the now.sh
domain.
The output in the image shows three different URLs:
- https://firstproject-2pv7khwwr.now.sh
- https://firstproject-sepia-ten.now.sh
- https://firstproject.flaviocopes.now.sh
Why are there multiple URLs?
The first URL is the identifier for the deploy. Every time you deploy your app, this URL will change.
You can test this immediately by making a change to your project code and running now
again:
The other two URLs will not change. The first one is a random URL, and the second one is derived from your project name (which defaults to the current project folder, your account name, and then now.sh
).
If you visit any of these URLs, you will see your app deployed in production:
Keep in mind that you can also configure Now to serve your app on a custom domain or subdomain, but that is beyond the scope of this tutorial. The now.sh
subdomain is sufficient for testing purposes.
Tags: Next.js, Now, deployment, Node.js, serverless, CDN