๐ What is Zeit?
ZEIT is the easiest way to deploy websites. Host your web projects with zero configuration, automatic SSL, and global CDN. You can visit their website https://zeit.co/ and explore more things.
In this article, we are going to deploy out expressjs web app to โฒ zeit now before we deep dive you have installed Node.js 10 LTS on your machine and zeit account.
Next install now globally on your machine using npm or yarn
$ npm i -g now
After installation configure your account
$ now login
Clone my repository
$ https://github.com/BhautikChudasama/Node-with-zeit.git
In this repository, I created the template of expressjs web app and you can also replace your code in index.js
Here is source code of index.js that sends the response Hello from zeit whenever / and for other wildcards, such /any, /aa, /xyz that sends wild card in response
Next we bind our app to 5000 port.
const express = require("express");
const app = express();
app.get("/", (req, res) => {
res.send("Hello from zeit");
});
app.get("**", (req, res) => {
res.send("wild card");
});
app.listen(5000, () => {
console.log("App is listening on port 5000");
});
Open your terminal and fire
$ now
that asks some basic questions
$ now
? Set up and deploy โF:\zeit-demoโ? [Y/n] y
? Which scope do you want to deploy to? Bhautik
? Link to existing project? [y/N] n
? Whatโs your projectโs name? zeit-demo
? In which directory is your code located? zeit-demo/
๏ฟฝ๐ Linked to ** (created .now and added it to .gitignore)
๏ฟฝ๐ Inspect: URL [Hidden]
โ
Production: https://zeit-demo-six.now.sh [copied to clipboard] [42s]
๏ฟฝ๐ Deployed to production. Run `now --prod` to overwrite later (https://zeit.ink/2F).
๏ฟฝ๐ก To change the domain or build command, go to URL [Hidden]
โ๏ธ After successful deployment that copied the production URL into the clipboard and now you can explore the app in your browser.
Try open https://zeit-demo-six.now.sh/ that show Hello from zeit and https://zeit-demo-six.now.sh/dev that show wild card in the response.
Thank you for reading my first article in dev.to and you can follow me on twitter also @bhautiktweets ๐
Top comments (0)