Request-Response

The Full-Stack Blog

Render Deployment Guide

May 28, 2024

This guide reviews the steps to set up a Render account and deploy an application to Render.

Account Setup

Render is a web hosting solution we will use for hosting full-stack applications. Renderwhich bills itself as "the fastest way to host all your web apps"allows us to easily deploy code from existing GitHub repositories. To get started, click the "Get Started For Free" button from the homepage, as shown in the following image:

Screenshot of the Render homepage. A button with the text "Get started for free" is near the bottom of the page.

Since we will be linking Render to our existing GitHub repositories, sign up with your existing GitHub account, as shown in the following image:

Screenshot of the Render sign up page.  A button with the text "GitHub" is near the top of the page, under a heading with the text "Sign up for Render".

Click the "Complete Sign Up" button, as shown in the following image (note that the email address has been edited out of the screenshot):

Screenshot of the Render sign up confirmation page. User email is displayed in an input field, and a button with the text "Complete Sign up" is near the bottom of the page.

You will need to confirm your account via a link in your email. Once you've done that, your account has been created!

Project Setup

You've likely already deployed a front-end application to a platform like GitHub Pages. But to deploy an application with a back end, you'll need a platform like Render that can handle the additional configurationso that your app can accept incoming connections from the internet.

To start, make sure that your project is initialized as a Git repository. You can check this by running the following command at the root of your project:

git status

If you encounter an error, that means that your project isn't yet a Git repository. You can initialize the repository by running the following command:

git init

Applications that feature an Express.js back end can use Render's PORT environment variable. To set this up, create a port variable with a value of process.env.PORT. You can also add a default value for local instances of your server by using the || syntax, as shown in the following example:

const port = process.env.PORT || 3001

Render allows you to deploy directly from a GitHub repository, so make sure you have committed and pushed your changes to your GitHub:

git add -A
git commit -m "<descriptive message here>"
git push

Now that we've created the repository, configured the server, and pushed to GitHub, we can create an app on Render and link it to our existing GitHub repository.

Create a Render App

The Render dashboard allows us to easily create an app and link an existing GitHub repository to it to deploy.

Create a new Render app by clicking the "New" button on the right side of the navbar, as shown in the following image:

Screenshot of the Render dashboard. A button with the text "New +" is on the right side of the navbar.

Select "Web Service" from the dropdown menu, as shown in the following image:

Screenshot of the Render dashboard after clicking on the "New +" button. A dropdown menu appears with several options.  The second choice has the text "Web Service".

Make sure "Build and deploy from Git repository" is selected, then click "Next," as shown in the following image:

Screenshot of the Render page for building a new Web Service. Two radio buttons exist in a form; the first radio button has the text "Build and deploy from Git repository." A button with the text "Next" is toward the bottom of the page.

If this is your first time deploying to Render, you will need to allow access to your GitHub repositories. Click on the "+ Connect account" link under the GitHub heading, as shown in the following image:

Screenshot of the Render create web service page. A link with the text "+ Connect account" is on the Right side of the page, under a heading with an icon of the Github logo and the text "GitHub".

Next, install Render to your GitHub account, providing access to all of your repositories, as shown in the following image:

Screenshot of the GitHub allow permissions page. A radio button with the text "All repositories" is selected in the middle of the page, and a button with the text "Install" is towards the bottom of the page.

Click the blue "Connect" button next to the repo you want to deploy. You can use the search box to filter out the repo you want, as shown in the following image:

Screenshot of the Render dashboard after connecting to GitHub. the term "fluff" has been entered into an input field toward the top of the page, and a button with the text "Connect" appears to the right of the filtered repository names"

Give your new Render app a unique name, as shown in the following image. It does not have to match the repo name, but it is useful to do so to keep track of which app is attached to which repo:

Screenshot of the Render create web service page. An input with the label "Name" is at the top of the page and has been given the value of "fluffy-spork".

Render needs to know which steps need to be taken to get your app up and running. In the case of an Express.js app, we need to run npm install to install all required dependencies. Scroll to the section "Build Command" and update the field to npm install. Render also needs to know which command to run to start your application. The "Start Command" field will be automatically populated with the start script from your package.json. Confirm that the "Start Command" is correct, as shown in the following image:

Screenshot of the Render create web service page partially scrolled from the top. An input with the label "Build Command" has been given the value of "npm install," and an input with the value of "start command" has been given the value "node index.js".

Make sure you leave the free tier selected, as shown in the following image:

Screenshot of the Render create web service page partially scrolled. A collection of radio buttons is displayed with various pricing options.  The first radio button, with the text "Free", is selected.

Now, we need to specify the node version in the Environment Variable section. Click the "Add Environment Variable" button, as shown in the following image:

Next, click the "Create Web Service" button, as shown in the following image:

Screenshot of the Render create web service page scrolled to the bottom. A button with the text "Create Web Service" appears at the bottom of the page.

The next page will log all the actions being taken to set up your server. Once your server goes live, you can use the provided link toward the top of the page to view your live site, as shown in the following image:

Screenshot of the Render web service instance page. A link to the live deployed site appears on the top left of the screen.

Resources

Visit the following link to supplement this guide:

This page was updated 2 months ago
© 2022 edX Boot Camps LLC. Confidential and Proprietary. All Rights Reserved.

Category: render

Tagged under: render, deployment, guide,

All Posts