Depolying a NodeJS App to Zeit with a remote database

January 31, 2018 0 Comments

Depolying a NodeJS App to Zeit with a remote database



Hello Again,

Most Developers have issues hosting their apps while its being built for testing purposes, so this article would guide you on how to host your NodeJS App on Zeit and use a remote database powered by mlab, so lets get started.

We would be using mlab as our remote database provider, I’d be guiding you on how to set up a mlab account.

To create a new account and set up a database, you will need to go here. I’ve provided the images below as a reference guide on setting up your database.

Create a new MongoDB Depoyment
select Amazon which is the free teir provider
select a region where you want your database to be hosted, select a region close to where you live for better performance
specify a name for your database, in my case i named mine zeit
confirm your specifications/order
go to the Users tab to create a new Database user
when done, the user created should pop up

Check the top of your dashboard you should see your credentials, in my case:

replace <dbuser> and <dbpassword> with the credentials of the user you just created

Download Zeit from here

Zeit Download Page

when you have Zeit Installed on your machine, run it and follow to initial setup prompt.

Clone our test repo from here using this command

git clone
Cloning our test repo

Zeit would not recognize any .env file or any environments file, we have to specify our DBHOST in the now command

now -e DBHOST=mongodb://<dbuser>:<dbpassword>

don’t forget to replace <dbuser> & <dbpassword> with the credentials of the user you created earlier.

press y to continue, when its done link would be automatically copied to clipboard

visit the link generated, here’s my link

It works

Now lets test the database, click on sample form

The form page

I am gonna submit the following details, you can submit whatever you like

The Submission

After Submitting whatever you fill in the form, check your mlab dashboard, you’d find out that a new collection has been created called users

The new collection

When we click on that collection we should see the details of what you filled in the form earlier, which means everything works.

The Details entered

At this point you should be proud of yourself, you now know how to:

  • Setup a remote MongoDB with mlab
  • Clone a Github repo (if you had no idea)
  • Deploy a NodeJS App to Zeit
  • Setting Environments Variables on Zeit

Don’t Forget to star the Repo we used here, you can contribute to the project also.


Tag cloud