This sample project demonstrates how to deploy a full-stack application using React for the frontend, Node.js for the backend, and PostgreSQL for the database.
In this sample, we have set up the essential files you need to deploy in production using Neon to host your database. We use a connection string to connect Neon to your code. By replacing the pre-configured connection string at .env and at the compose file to yours, you will be ready to deploy this sample with Neon.
- Download Defang CLI
- (Optional) If you are using Defang BYOC authenticate with your cloud provider account
- (Optional for local development) Docker CLI
To run the application locally, you can use the following command:
docker compose -f compose.dev.yaml up --buildOr run without using Docker by doing the following:
- run
npm installto install the nodejs dependencies in both theclientdirectory and theserverdirectory - create or modify the .env file in both the
clientdirectory and theserverdirectory with localhost, or create a .env.local to override the .env file. - run
npm start
For this sample, you will need to provide the following configuration:
Note that if you are using the 1-click deploy option, you can set these values as secrets in your GitHub repository and the action will automatically deploy them for you.
A connection to the database, which should be in the format of postgres://username:password@host:port/dbname.
defang config set DATABASE_URLA URL for the React App. For this, you will need to update the compose.yaml file to replace <YOUR_USERNAME> with your username, which you can get by running defang whoami.
Note
Download Defang CLI
Deploy your application to the Defang Playground by opening up your terminal and typing:
defang compose upIf you want to deploy to your own cloud account, you can use Defang BYOC:
Title: Node.js & React & PostgreSQL
Short Description: A full-stack to-do list application.
Tags: Node.js, React, Full-stack, PostgreSQL, JavaScript, SQL
Languages: nodejs