https://github.com/rifandani/next-connect-passport-auth
next auth boilerplate
https://github.com/rifandani/next-connect-passport-auth
Last synced: 4 months ago
JSON representation
next auth boilerplate
- Host: GitHub
- URL: https://github.com/rifandani/next-connect-passport-auth
- Owner: rifandani
- Created: 2020-06-21T13:58:20.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T09:30:38.000Z (almost 3 years ago)
- Last Synced: 2025-01-21T15:49:13.019Z (9 months ago)
- Language: JavaScript
- Size: 534 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# next-connect and Passport
This example creates a basic [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) app using [next-connect](https://github.com/hoangvvo/next-connect) and cookie-based authentication with [Passport.js](http://www.passportjs.org/). The cookie is securely encrypted using [@hapi/iron](https://github.com/hapijs/iron).
The example shows how to do a sign up, login, logout, and account deactivation. It utilizes [SWR](https://swr.now.sh/) to fetch the API.
For demo purpose, the users database is stored in the cookie session. You need to replace it with an actual database to store users in [db.js](lib/db.js).
In production, you must use a password hashing library, such as [argon2](https://github.com/ranisalt/node-argon2) or [bcrypt](https://www.npmjs.com/package/bcrypt).
## Deploy your own
Deploy the example using [Vercel](https://vercel.com):
[](https://vercel.com/import/project?template=https://github.com/vercel/next.js/tree/canary/examples/with-passport-and-next-connect)
## How to use
Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example:
```bash
npx create-next-app --example with-passport-and-next-connect with-passport-and-next-connect-app
# or
yarn create next-app --example with-passport-and-next-connect with-passport-and-next-connect-app
```Deploy it to the cloud with [Vercel](https://vercel.com/import?filter=next.js&utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).