If you write personal programming projects, you probably need a place to deploy them, preferably for free.
There are many free hosting platforms if you have a frontend-only application / static website, but not so many if you also have a backend / API.
AWS has a free tier, but also a big learning curve.
What if you could...
... for completely free?
Vercel lets us deploy not just the frontend, but the backend too.
You can also connect to a database from the Vercel backend.
It's a serverless platform, but you don't have to know how to write lambda functions.
You can deploy an ordinary Express.js or Flask app on it.
(If you want to write serverless functions, you can do that too.)
I'm not affiliated with Vercel and it does not pay me, I just really like it.
The sample application is a simple app with one route.
You can check out this Github repository and create your own repository off of it.
From the following Github repository
https://github.com/elze/vercel-express-react-demo
let's check out the v1
tag:
v1
tag page, download the .zip
or the tar.gz
versionYou will create a new repository using this as a basis.
<your-Github-id>-vercel-express-react-demo
cd
into this directory.git init
- this will create a new git repository named after the directory.cd
into the api
subdirectory.npm install
node index.js
This should start the Express.js server. You can visit it at
http://localhost:8081/api/skills
The port number may be different - the command line output will tell you what port it is running on.
The data that comes through does not make much sense, it's only used for the demo purposes.
cd
into the top-level directory in the app (in a different terminal)npm install
npm start
This should start the React.js server. You can visit it at
http://localhost:3000
The data that comes through does not make much sense, it's only used for the demo purposes.
It should look like what you see in this page:
https://vercel-express-react-demo.vercel.app/
Push your repository to Github.
Now you can connect it to Vercel.
Search for and select a Github repository you want to deploy on Vercel.
Leave the defaults in place and click "Deploy" (open the screenshot in a separate tab to see the "Deploy" button)
After the deployment succeeds, Vercel will give you the URL at which you can access your app.
E.g. https://vercel-express-react-demo.vercel.app/
If the deployment fails, there will be a link to the logs where you can see why it failed.
The best thing (can also be a bad thing) -
Whenever you push to Github, your application will be automatically redeployed!
You can also deploy to Vercel without going through Github.
Once you have signed up for Vercel, you can deploy a project there without even having a Github repository for it.
If your repository is connected to Vercel, you can still deploy it without pushing to Github first.
For that, you need to install Vercel command line tool from npm
.
Then, in the project top-level directory (the one that has package.json, etc.), type vercel
.
Vercel will ask you some questions (you'll probably want to choose the default answers) and deploy your code.
https://vercel.com/guides/using-express-with-vercel -- Vercel's own guide to running Express.js apps on it.
Questions? Feel free to email me: elze.hamilton@gmail.com