Deploy RedwoodJS with Vercel

Create a Redwood blog and deploy it live with Vercel.

RedwoodJS is an opinionated, full-stack, serverless web application framework that will allow you to build and deploy JAMstack applications with ease.

In this guide, you will discover how to create and deploy a Redwood blog to Vercel, backed by a PostgreSQL database connection.

Step 1: Creating Your Redwood App

Set up a new Redwood app by cloning the project template and moving into the project directory:

git clone -b vercel-deploy https://github.com/redwoodjs/example-blog.git

Initializing a Redwood app locally.

Move into the project directory and remove the origin remote:

cd example-blog && git remote rm origin

Moving into the project directory and removing the origin remote.

Install the project dependencies with Yarn:

yarn install

Installing the project dependencies with Yarn.

Create a local SQLite database and seed it with the provided blog posts:

yarn redwood db up && yarn redwood db seed

Creating and seeding a local SQLite database.

Note: When importing the project to Vercel, you will need to add an environment variable with the name DATABASE_URL, this will hold the value of a supplied PostgreSQL connection string. If needed, you can quickly spin up a free database on Heroku.

Use the provided Redwood script to set Vercel as the deployment target:

yarn redwood generate deploy vercel

Setting the the project deployment target to Vercel.

Your Redwood app is now ready for local development with the following command:

yarn redwood dev

Running the Redwood app locally.

Step 2: Seed Your PostgreSQL Database

In the .env.defaults file, change your DATABASE_URL environment variable to your PostgreSQL connection string.

Then, as in step 1, run the following command to seed your PostgreSQL database:

yarn redwood db up && yarn redwood db seed

Seeding your PostgreSQL database with blog posts.

After this command has been executed, change your DATABASE_URL back to file:/dev.db so that it uses the SQLite database during local development.

By seeding your PostgreSQL database, you will be providing your database with content to display for when you deploy your Redwood blog in step 3.

Step 3: Deploy Your App with Vercel

To deploy your Redwood app with a Vercel for Git Integration, make sure it has been pushed to a Git repository.

During the import process, you will need to add the following environment variable:

  • DATABASE_URL

Import the project into Vercel using your Git Integration of choice:

After your project has been imported, all subsequent pushes to branches will generate Preview Deployments, and all changes made to the Production Branch (commonly "main") will result in a Production Deployment.

Once deployed, you will get a URL to see your app live, such as the following: https://redwoodjs-example-blog.vercel.app/

Set up a Redwood app with a few clicks using the Deploy button, and create a Git repository for it in the process for automatic deployments for your updates.

Bonus: Learn More about Redwood

After deploying your Redwood app, learn more about how it works and dive deeper with the resources below:



Written By
Written by mcsdevmcsdev
Last Edited on August 21st 2020