/react-postgres-boilerplate

A boilerplate to start your project by intergrating PostgreSQL with create-react-app through an API made with Node.js/Express.js and node-postgres

Primary LanguageJavaScriptMIT LicenseMIT

create-react-app with PostgreSQL intergration

This repo was created to show how to connect a Postgres database with react, do not use in production. It's currently unmaintained so make sure you update the dependencies before using.

Get started

Install dependencies

  • $npm install

Login to the database

  • Create a .env file similar to the .env.example.env or modify the current file
  • Include your PostgreSQL username, password, database and port.

Map the data

  • Modify the App.js file when mapping the data so that it corresponds to the database collumn name

  • {item.<yourCollumnName>}

Configure the PostgreSQL query

  • The query in api.js must correspond to the database table name

  • client.query("SELECT * FROM <yourTableName>", function(err, result) {})

Start your API

Start your Application