

Next.js (React) + Redux + REST API + Postgres SQL boilerplate
source link: https://www.tuicool.com/articles/hit/mqUvaaq
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Next.js (React) + Redux + Express REST API + Postgres SQL boilerplate
Why is this awesome?
This is a great starting point for a any project where you want React + Redux (with server-side rendering, powered by Next.js ) as frontend and Express/Postgres SQL as a REST API backend. Lightning fast, all JavaScript.
- Simple REST API routes with
sql-wizard
. - Redux REST support with
redux-api
andnext-redux-wrapper
. - Flexible client-side routing with
next-routes
(seeserver/routes.js
). - Flexible configuration with
config/config.js
and.env
file. - Hot reloading with
nodemon
. - Testing with Jasmine.
- Code formatting and linting with StandardJS.
- JWT authentication for client-server communication (coming).
Demo
See nextjs-sql-rest-api-boilerplate running on Heroku here .
How to use
Clone this repository:
git clone https://github.com/tomsoderlund/nextjs-sql-rest-api-boilerplate.git [MY_APP]
Install dependencies:
cd [MY_APP] yarn # or npm install
Install Postgres and set up the database:
psql postgres # Start the Postgres command-line client CREATE DATABASE "nextjs-sql-rest-api-boilerplate"; -- You can also use \connect to connect to existing database CREATE TABLE kitten (id serial, name text); -- Create a blank table INSERT INTO kitten (name) VALUES ('Sphynxie'); -- Add example data SELECT * FROM kitten; -- Check data exists \q
Start it by doing the following:
export DATABASE_URL=[your Postgres URL] # Or use a .env file yarn dev
In production:
yarn build yarn start
If you navigate to http://localhost:3123/
you will see a Next.js page with a list of kittens (or an empty list if you haven’t added one).
Your API server is running at http://localhost:3123/api/kittens
Deploying
Deploying on Heroku
heroku create [MY_APP] heroku addons:create heroku-postgresql:hobby-dev git push heroku master
Deploying on Now
(Coming)
Recommend
-
133
boilerplate with Babel, hot reloading, testing, linting and a working example app built in...
-
64
Next.js + React Hooks + GraphQL (Apollo) + Postgres SQL boilerplate Note: this is my v3 boilerplate for React web apps. See also n...
-
26
React JS with Redux and Saga Project Structure A ready-to-use boilerplate for React JS with Redux and Saga. Project Overview This is a basic project structure with repeatative use cases....
-
8
Accessing Postgres via REST using pRest Sep 3 ・5 min read
-
4
-
10
This tutorial will show you how to use react-select to create an async dropdown. I’m also utilising useState hooks to set and receive selected values, as well as Axios to retrieve data from the rest API. I have already...
-
24
Building REST APIs in Golang go-gin with persistence database Postgres Let's build REST APIs in Go using
-
4
Blog postPostgres Full Text Search vs the rest2022-10-1414 minute read
-
12
Originally posted on divrhino.com In this tutorial, we will learn how to create a simple trivia REST API from scratch, using Go and...
-
7
express-mongodb-rest-api-typescript-boilerplate Also
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK