How to Deploy Your Node.js App for Free with Cyclic

How to Deploy Your Node.js App for Free with Cyclic

Deploying your NodeJS app can be a hassle if you choose to do it with a VPS. You have to setup the server, from the firewall, to authentication, to installing the necessary utilities, etc. Although this offers for a lot of control and flexibility, but what if you just want to deploy your app as quickly as possible, and not worry about server setup and maintenance? That is where serverless architecture provided by platforms like Cyclic come in.

What is serverless architecture?

Serverless architecture is a model that lets developers build and run their web apps without having to manage the infrastructure that their apps are built on. The word serverless is not to be taken literally here as servers are still used to run the apps.

Advantages of serverless architecture:

Disadvantages of serverless architecture:

Now that we summarized what serverless architecture is, let us look at how deploying a NodeJS app can be seamless with this model.

Deploying a NodeJS app with Cyclic

First, ensure you have the following requirements:

Part 1

Create a project folder locally, cd into it, and clone the starter code for a readily-made NodeJS app. If you wish to use your own NodeJS project, you can skip this part and jump to part 3.

git clone https://github.com/ZiyadBoshima/nodejs-starter-code

Once that is done, run the following command to install the dependencies:

npm install

Ensure the project is working by running this command:

npm start

Then click on this link to see the server response: http://localhost:5000/. If you see the page below, that means everything works fine and you are ready to move to the next part.

Part 2

Login to your GitHub account and create a remote repository.

Now you want to connect the remote repository with your project. Run the following commands in order, and replace with the link of the remote repository that you created:

git remote add origin <your repo>
git branch -M main
git push -u origin main

Part 3

Now it is time to visit cyclic.sh and sign up with your Github account. Once you are on your dashboard, click on the "Link Your Own" tab. Then, select your repo.

You will then be prompted to connect Cyclic to your repo. Click on "Connect Cyclic".

Then, click on "Approve & Install".

Once redirected back, let your Cyclic build & deploy your app.

When the build is complete, you should see your api link at the very bottom.

And there we go, your app is deployed and can be accessed using a link generated by cyclic. You can view the link anytime in your dashboard.

Clicking the link should show the same output as when we ran the app locally:

And that is all it takes to deploy your NodeJS app. Quite simple, isn't it?

Additional Comments

Now, one issue I faced when I first deployed an app was that Cyclic complained about nodemon in the start script of package.json. Cyclic must use node to run the app, not nodemon. If you used the starter code from my Github repo, you will not face this issue; if you used your own node project, ensure your start script looks like this:

Conclusion

That is all for this tutorial. If you find Cyclic awesome, and would like to continue working with it, consider using my referral link: https://app.cyclic.sh/#/join/ZiyadBoshima

<- Back Home

Powered by Outstatic and Vercel

Berlin  4:14 PM