{"id":23278754,"url":"https://github.com/jimmylee/next-postgres","last_synced_at":"2025-10-07T06:14:07.646Z","repository":{"id":56185280,"uuid":"241533537","full_name":"jimmylee/next-postgres","owner":"jimmylee","description":"[OUTDATED] A minimal example web application using NextJS 12.0.7, Postgres 11, Google OAuth2 and other useful libraries.","archived":false,"fork":false,"pushed_at":"2024-01-09T20:54:58.000Z","size":92,"stargazers_count":70,"open_issues_count":0,"forks_count":9,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-08-29T18:49:28.996Z","etag":null,"topics":["emotion","google-authentication","nextjs","oauth2","postgres","react"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jimmylee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-02-19T04:36:24.000Z","updated_at":"2023-10-27T17:33:14.000Z","dependencies_parsed_at":"2025-08-21T11:38:20.529Z","dependency_job_id":"d554c171-98a5-46c7-9930-d341900093ea","html_url":"https://github.com/jimmylee/next-postgres","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/jimmylee/next-postgres","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimmylee%2Fnext-postgres","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimmylee%2Fnext-postgres/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimmylee%2Fnext-postgres/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimmylee%2Fnext-postgres/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jimmylee","download_url":"https://codeload.github.com/jimmylee/next-postgres/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimmylee%2Fnext-postgres/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278729204,"owners_count":26035599,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["emotion","google-authentication","nextjs","oauth2","postgres","react"],"created_at":"2024-12-19T22:34:30.335Z","updated_at":"2025-10-07T06:14:07.578Z","avatar_url":"https://github.com/jimmylee.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## DEPRECATION NOTICE\n\nThis template is no longer up to date. For an updated template, either as a team or individually, we encourage you to explore our [latest template](https://github.com/internet-development/nextjs-sass-starter) produced by [INTDEV](https://internet.dev). Thank you for your interest in our work! \n\n# next-postgres\n\n\u003e **January 4th, 2022** ➝ _I recommend you use [www-react-postgres](https://github.com/jimmylee/www-react-postgres) instead because it does not have an `express` server or a need for `babel`, therefore the template has less dependencies. That means there will be less attention cost required._\n\nThis setup is using:\n\n- [NextJS 12.0.7](https://nextjs.org/)\n- [Postgres 11](https://github.com/brianc/node-postgres)\n- [Express 4.17.2](https://github.com/expressjs/express)\n- [Emotion CSS-in-JS 11.7.1](https://5bb1495273f2cf57a2cf39cc--emotion.netlify.com/)\n- [GoogleAPIs 92.0.0](https://github.com/googleapis/google-api-nodejs-client#readme)\n- [Knex 0.95.15](https://knexjs.org/)\n\nIt is for:\n\n- Running a website with users.\n- Using [Google web browser OAuth](https://developers.google.com/identity).\n- Replacing my old work with [next-postgres-sequelize](https://github.com/jimmylee/next-postgres-sequelize).\n- Deploying with [https://render.com](https://render.com) or something like it.\n\n## Setup\n\n#### Step 1\n\nClone this repository!\n\n#### Step 2\n\nCreate an `.env` file at your project root.\n\n```sh\nCLIENT_ID=GET_ME_FROM_GOOGLE\nCLIENT_SECRET=GET_ME_FROM_GOOGLE\nJWT_SECRET=74b8b454-29a6-4282-bdec-7e2895c835eb\nPASSWORD_SECRET=\\$2b\\$10\\$oaBusYfHLawNiFDqsqkTM.\n```\n\n- Generate your own `PASSWORD_SECRET` with `BCrypt.genSaltSync(10)`. You need to escape `$` signs.\n- Generate your own `JWT_SECRET`.\n- Obtain `CLIENT_ID` and `CLIENT_SECRET` from [https://console.developers.google.com](https://console.developers.google.com) after you setup your application.\n- Use `CMD+F` to find `REDIRECT_URIS` in `~/common/credentials`. Google needs this string for the **Authorized redirect URIs** setting. The default is: `http://localhost:1337/sign-in-confirm`.\n\n#### Step 3\n\nThis is important. Enable [People API](https://console.developers.google.com/apis/api/people.googleapis.com/overview). Otherwise Google Auth will not work.\n\n## Setup: Running the website (OSX)\n\nAll steps assume you have [Homebrew](https://brew.sh/) installed on your machine. You might want to install [iTerm](https://iterm2.com/) since you need multiple terminal windows open as well.\n\nUsing another version of Postgres? That may be okay. I use Postgres 11 to share versions with [Render](https://render.com/) but I have tried these steps with Postgres 9 as well.\n\n#### Installing Postgres 11\n\nMileage may vary with a different version.\n\n```sh\nbrew uninstall postgresql\nbrew install postgresql@11\nbrew link postgresql@11 --force\n```\n\n#### Installing Node\n\nMake sure NodeJS version 10+ is installed on your machine.\n\n```sh\nbrew install node\n```\n\n#### Installing nodemon\n\nWe use `nodemon` to reload the site whenever changes are made locally.\n\n```sh\nnpm install -g nodemon\n```\n\n#### Installing Node packages\n\nOnce you have Postgres and Node, run these commands:\n\n```sh\nnpm install\nnpm run dev\n```\n\n#### Run Postgres\n\nIn a seperate terminal tab run your postgres version, in this case the command below is referencing Postgres 11.\n\n```sh\npostgres -D /usr/local/var/postgresql@11 -p 1334\n```\n\nYou may need to run `brew services stop postgresql@11` since we're running postgres on a different port.\n\nIf you get an error that `lock file \"postmaster.pid already exists` like I did, you can delete that file with something like `rm /usr/local/var/postgresql@11/postmaster.pid`.\n\n#### Create a new database\n\n- Start with creating an admin user.\n- Finish with creating a database for testing.\n\n```sh\n# Enter Postgres console\npsql postgres -p 1334\n\n# Create a new user for yourself\nCREATE ROLE admin WITH LOGIN PASSWORD 'oblivion';\n\n# Allow yourself to create databases\nALTER ROLE admin CREATEDB;\n\n# You need to do this to install uuid-ossp in a later step\nALTER USER admin WITH SUPERUSER;\n\n# Exit Postgres console\n\\q\n\n# Log in as your new user.\npsql postgres -p 1334 -U admin\n\n# Create a database named: nptdb.\n# If you change this, update knexfile.js\nCREATE DATABASE nptdb;\n\n# Give your self privileges\nGRANT ALL PRIVILEGES ON DATABASE nptdb TO admin;\n\n# List all of your databases\n\\list\n\n# Connect to your newly created DB as a test\n\\connect nptdb\n\n# Exit Postgres console\n\\q\n```\n\n## Setup: Fill database with tables\n\nRun the following commands:\n\n```sh\nnpm run do-setup-database\nnpm run do-seed-database\n```\n\n## View the website\n\nView `http://localhost:1337` in your browser.\n\n### Scripts\n\nIf you need to run node script without running the server, use this example to get started\n\n```sh\nnpm run script example\n```\n\n## Setup: Production deploy\n\nComing soon.\n\n## Questions?\n\nFeel free to slang any feels to [@wwwjim](https://twitter.com/wwwjim).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjimmylee%2Fnext-postgres","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjimmylee%2Fnext-postgres","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjimmylee%2Fnext-postgres/lists"}