{"id":19321058,"url":"https://github.com/itsdrvgo/nextjs-jwt-auth-example","last_synced_at":"2026-03-03T20:33:29.020Z","repository":{"id":239814120,"uuid":"776776919","full_name":"itsdrvgo/nextjs-jwt-auth-example","owner":"itsdrvgo","description":"A simple example of JWT based authentication in Next.js.","archived":false,"fork":false,"pushed_at":"2024-03-24T13:15:18.000Z","size":131,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-31T19:22:52.762Z","etag":null,"topics":["authentication","drizzle-orm","jwt","nextjs","postgresql","redis"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/itsdrvgo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","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}},"created_at":"2024-03-24T13:15:14.000Z","updated_at":"2024-11-24T07:52:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"4955ac9d-00b7-4998-92be-05dae1b11076","html_url":"https://github.com/itsdrvgo/nextjs-jwt-auth-example","commit_stats":null,"previous_names":["itsdrvgo/nextjs-jwt-auth-example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/itsdrvgo/nextjs-jwt-auth-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsdrvgo%2Fnextjs-jwt-auth-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsdrvgo%2Fnextjs-jwt-auth-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsdrvgo%2Fnextjs-jwt-auth-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsdrvgo%2Fnextjs-jwt-auth-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itsdrvgo","download_url":"https://codeload.github.com/itsdrvgo/nextjs-jwt-auth-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsdrvgo%2Fnextjs-jwt-auth-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30058301,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-03T18:21:05.932Z","status":"ssl_error","status_checked_at":"2026-03-03T18:20:59.341Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["authentication","drizzle-orm","jwt","nextjs","postgresql","redis"],"created_at":"2024-11-10T01:35:09.976Z","updated_at":"2026-03-03T20:33:29.000Z","avatar_url":"https://github.com/itsdrvgo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JWT Based Authentication | Next.JS Example\n\n## **⚠️!!Warning!!⚠️**\n\nThis project is my first attempt to create an Authentication system from scratch. And it may contain security vulnerabilities. Please use it for educational purposes only. Do not use it in production. If you find any security vulnerabilities and you know how to fix them, please create a pull request. I'll be happy to learn from you.\n\n## Introduction\n\nThis example shows how to use JWT based authentication in Next.js. The whole system is made from scratch, including the backend and frontend. Here is the list of technologies used in this example:\n\n-   [Next.js](https://nextjs.org/) - A Modern React Framework for building websites.\n-   [Supabase Postgres](https://supabase.com/) - The open source Firebase alternative. Used for storing user data.\n-   [Drizzle ORM](https://orm.drizzle.team/) - A simple, type-safe and lightweight ORM for SQL databases.\n-   [T3 ENV](https://env.t3.gg/) - A simple and secure way to manage environment variables in Next.js.\n-   [ShadCN UI](https://ui.shadcn.com/) - A simple and beautiful UI library for React.\n-   [jose](https://github.com/panva/jose) - A JavaScript implementation of the JSON Object Signing and Encryption (JOSE) for JWTs.\n-   [bcryptjs](https://github.com/dcodeIO/bcrypt.js) - Optimized bcrypt in plain JavaScript with zero dependencies.\n-   [Upstash Redis](https://upstash.com/) - A simple and fast Redis as a service.\n\n## Features\n\n-   **Authentication** - JWT based authentication system.\n-   **Authorization** - Protect routes from unauthorized access.\n-   **User Management** - Register, login, logout, and authorization based actions.\n-   **Environment Variables** - Securely manage environment variables.\n\n## Getting Started\n\nFirst, clone the repository:\n\n```bash\ngit clone https://github.com/itsdrvgo/nextjs-jwt-auth-example.git\n```\n\nThen, install the dependencies:\n\n```bash\ncd nextjs-jwt-example\n\nbun install\n# or\nnpm install\n```\n\nAfter that, create a `.env.local` file in the root directory and copy the content from `.env.example` to it. Fill the environment variables with your own values.\n\nTo generate secret keys for JWT, enter REPL mode in Node.js / Bun:\n\n```bash\n# For Node.js\nnode\n\u003e require('crypto').randomBytes(64).toString('hex')\n\n# For Bun\nbun repl\n\u003e require('crypto').randomBytes(64).toString('hex')\n```\n\nCopy the generated secret keys to the `.env.local` file. You'll have slots for two secret keys, one for access tokens and one for refresh tokens. It's recommended to use different keys for both.\n\nNow, you can start the development server:\n\n```bash\nbun run dev\n# or\nnpm run dev\n```\n\nOpen [localhost](http://localhost:3000) in your browser to see the application.\n\n## Conclusion\n\nThis example is a simple demonstration of how to use JWT based authentication in Next.js. It's not production-ready and may contain security vulnerabilities. Please use it for educational purposes only. If you find any security vulnerabilities and you know how to fix them, please create a pull request. I'll be happy to learn from you.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Feedback\n\nFeel free to send me feedback on [X](https://x.com/itsdrvgo) or file an issue. Feature requests are always welcome. If you wish to contribute, please take a quick look at the [CONTRIBUTING.md](CONTRIBUTING.md) file.\n\nJoin our Discord server [here](https://dsc.gg/drvgo)!\n\n## Connect with me\n\n[![Instagram](https://img.shields.io/badge/Instagram-%23E4405F.svg?logo=Instagram\u0026logoColor=white)](https://instagram.com/itsdrvgo)\n[![LinkedIn](https://img.shields.io/badge/LinkedIn-%230077B5.svg?logo=linkedin\u0026logoColor=white)](https://linkedin.com/in/itsdrvgo)\n[![Twitch](https://img.shields.io/badge/Twitch-%239146FF.svg?logo=Twitch\u0026logoColor=white)](https://twitch.tv/itsdrvgo)\n[![X](https://img.shields.io/badge/X-%23000000.svg?logo=X\u0026logoColor=white)](https://x.com/itsdrvgo)\n[![YouTube](https://img.shields.io/badge/YouTube-%23FF0000.svg?logo=YouTube\u0026logoColor=white)](https://youtube.com/@itsdrvgodev)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitsdrvgo%2Fnextjs-jwt-auth-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitsdrvgo%2Fnextjs-jwt-auth-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitsdrvgo%2Fnextjs-jwt-auth-example/lists"}