DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป is a community of 966,904 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Cover image for Deploy Express.js app to Vercel
Ha Tuan Em
Ha Tuan Em

Posted on • Updated on

Deploy Express.js app to Vercel

After research how to deploy Express.js app to Vercel. Finally, I found and got have an application has deployed to Vercel. It's take a lot of time from me but I am happy and hope this article will help something to you.

I. First of all, creating new Github repository and init new project nodejs.

Clone and init project

II. Creating new project in Vercel

image

III. Installing package express to nodejs app.

install express package

IV. Creating and endpoint file index.js in root source.

Creating index.js file

V. Creating APIs in ./api folder or you can rename anything which you like.

  • Here is an example for manage product from ./api/product.

API folder

VI. Testing before commit source to Github.

Testing

  • After testing is ๐Ÿ‘Œ. Commit them to git to see something awesome.

VII. Ready to serve in Vercel.

image

VIII. Something went wrong in Vercel.

image

  • Because Vercel just supports API from Framework JS as NEXT.JS, Nuxt.JS,... So if we develop a standalone application we need to configure or tell the server of Vercel how is it work by vercel.json file.

IX. Add new vercel.json file to root source.

  • Commit it to GitHub and make sure version is 2 - this is required from Vercel.

Vercel.json file

X. Done, enjoy your moment.

Thanks for reading.
And I hope something good to you.
Here is repository which use in this post.


Buy me a coffee

XI. Or you can follow this tutorial in youtube.

Top comments (20)

Collapse
 
catur profile image
Catur Wicaksono

this is awesome.. but when i try to build using express generator, it doesn't work, is there any help :(

Collapse
 
hte305 profile image
Ha Tuan Em Author

Vercel is not supporting the Express Generator at the moment. Becasue it's attach to the pattern of serverless. Instead, you can use express traditional. Thanks.

Collapse
 
mohaymenrafi profile image
mohaymen_rafi

Thanks!

Collapse
 
jdgamble555 profile image
Jonathan Gamble

Could you show us how to do this with Angular Universal or NestJS?

Collapse
 
hte305 profile image
Ha Tuan Em Author

I will try it.

Collapse
 
erfelipee profile image
Felipe

Thanks!

Collapse
 
lassev profile image
lasse

So i created an api with express
can i use vercel to deploy it?

Collapse
 
hte305 profile image
Ha Tuan Em Author

Yes, you can.

Collapse
 
samx23 profile image
Sami Kalammallah

How about a full stack app where I use express on folder /server and react on /client ?

Collapse
 
hte305 profile image
Ha Tuan Em Author

Waiting for my new post ๐Ÿ˜€

Collapse
 
barhoumimohamedali profile image
Barhoumimohamedali

thanks , this is really useful!

Collapse
 
khalby786 profile image
Khaleel Gibran

This is really great, but isn't that the whole point of serverless functions?

Collapse
 
hte305 profile image
Ha Tuan Em Author

Actually, Express is a traditional server. It's not supported by serverless. But you still want to covert Express to serverless app. You can find out in this article. But I recommend you should using Next.js to making an awesome application with full serverless function.
Thanks =)

Collapse
 
fecocode profile image
Feco

Thanks @hte305 !

Collapse
 
hte305 profile image
Ha Tuan Em Author

Hope, it helps something to you.

Collapse
 
kamalhossain profile image
Kamal Hossain

Is it completely free?

Collapse
 
hte305 profile image
Ha Tuan Em Author • Edited on

As you wish ๐Ÿ˜‰

Collapse
 
rst1705 profile image
MechInTech

this is awsome ,hey can i use mongodb data base for this as well

Collapse
 
letsbsocial1 profile image
Maria Campbell

I'm working on a next.js app which uses mongod and host my backend on MongoDB Atlas. Yes, you can use MongoDB. And better yet would be to use Mongoose because of its schemas.

Collapse
 
kbcruz6 profile image
Agustin Cruz

Hi ! I am having an issue, I can see my express app (which has front too) in localhost successfully, but when i deploy it in vercel, I cannot see the app, what should i do?}
ThankS!

๐ŸŒš Life is too short to browse without dark mode