Did you or your company find nextjs-pwa-graphql-sql-boilerplate useful? Please consider giving a small donation, it helps me spend more time on open-source projects:
Why is this awesome?
This is a great template for a any project where you want React (with Hooks) (with server-side rendering, powered by Next.js) as frontend and GraphQL and Postgres SQL as backend.
Lightning fast, all JavaScript.
Remove the .git folder since you want to create a new repository
rm -rf .git
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-pwa-graphql-sql"; -- You can also use \connect to connect to existing database
\connect "nextjs-pwa-graphql-sql";
CREATE TABLE article (id serial, title varchar(200), content text); -- Create a blank table
INSERT INTO article (title) VALUES ('The first article'); -- Add example data
SELECT * FROM article; -- Check data exists
\q
Configure the .env file.
Start it by doing the following:
yarn dev # or 'yarn now' to run with Zeit Now serverless
In production:
yarn build
yarn start
If you navigate to http://localhost:3003/ you will see a web page with a list of articles (or an empty list if you haven’t added one).
GraphQL client and server
Your GraphQL API server is running at http://localhost:3003/api/graphql.
Try the GraphQL playground on the demo server.
Deploying
You can either deploy as a serverless deployment, or as a traditional Express server.
Depending on which deployment you make, some files are unnecessary*.
请发表评论