{"id":20535633,"url":"https://github.com/definitelynotchirag/auth-nextjs","last_synced_at":"2026-05-21T16:09:08.850Z","repository":{"id":234920704,"uuid":"789738856","full_name":"definitelynotchirag/auth-nextjs","owner":"definitelynotchirag","description":"NextJs Authentication using JWT token and Verification with forgot password functionality.","archived":false,"fork":false,"pushed_at":"2024-04-21T12:42:06.000Z","size":75,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-16T13:54:15.667Z","etag":null,"topics":["authentication","forgot-password","jwt-authentication","login-page","nextjs14","signup-page","verification"],"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/definitelynotchirag.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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}},"created_at":"2024-04-21T12:28:44.000Z","updated_at":"2024-12-30T04:03:00.000Z","dependencies_parsed_at":"2024-04-21T15:07:12.398Z","dependency_job_id":"c647ae46-b1ad-4e6d-bf97-779a7c835d6b","html_url":"https://github.com/definitelynotchirag/auth-nextjs","commit_stats":null,"previous_names":["definitelynotchirag/auth-nextjs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/definitelynotchirag%2Fauth-nextjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/definitelynotchirag%2Fauth-nextjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/definitelynotchirag%2Fauth-nextjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/definitelynotchirag%2Fauth-nextjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/definitelynotchirag","download_url":"https://codeload.github.com/definitelynotchirag/auth-nextjs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242140643,"owners_count":20078376,"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","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","forgot-password","jwt-authentication","login-page","nextjs14","signup-page","verification"],"created_at":"2024-11-16T00:33:06.216Z","updated_at":"2026-05-21T16:09:03.809Z","avatar_url":"https://github.com/definitelynotchirag.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Auth-Nextjs\n\nImplementing authentication with JWT tokens in Next.js involves several steps, including user registration, login, token generation, and verification. Additionally, implementing forgot password functionality typically involves sending a reset password email to the user. Here's a high-level overview of how you can implement these features:\n\n### User Registration:\nCreate a registration form with fields like email and password.\nWhen the form is submitted, send a POST request to your server with the user's credentials.\nOn the server, hash the password and save the user's details (including the hashed password) to your database.\n![User Registration](https://telegra.ph/file/8d5ceb36932a991e8f9f9.png)\n\n### User Login:\nCreate a login form with fields for email and password.\nWhen the form is submitted, send a POST request to your server with the user's credentials.\nOn the server, verify the user's credentials, and if they are correct, generate a JWT token.\nSend the JWT token back to the client and store it securely (e.g., in local storage or a cookie).\n![User Login](https://telegra.ph/file/462bb3b1ef210311f8694.png)\n\n### JWT Token Generation:\nUse a library like jsonwebtoken to generate JWT tokens on the server.\nInclude the user's ID or other identifying information in the token payload.\n\n### JWT Token Verification:\nCreate a middleware function to verify JWT tokens on protected routes.\nExtract the token from the request headers or cookies and verify it using the jsonwebtoken library.\nIf the token is valid, allow access to the protected route; otherwise, return a 401 unauthorized error.\n\n### Forgot Password Functionality:\nCreate a forgot password form where users can enter their email address.\nWhen the form is submitted, generate a unique reset token and store it in your database along with the user's ID and an expiration time.\nSend a reset password email to the user's email address with a link containing the reset token.\nWhen the user clicks the link, verify the reset token and allow them to reset their password.\n![Forgot Password](https://telegra.ph/file/59337a83a055b52f8935a.png)\n\n### Reset Password:\nCreate a reset password form where users can enter a new password.\nWhen the form is submitted, verify the reset token and the user's ID.\nIf the verification is successful, hash the new password and update the user's password in the database.\n\n## Getting Started\n\nFirst, run the development server:\n\n```bash\nnpm run dev\n# or\nyarn dev\n# or\npnpm dev\n# or\nbun dev\n```\n\nOpen [http://localhost:3000](http://localhost:3000) with your browser to see the result.\n\n\n## Learn More\n\nTo learn more about Next.js, take a look at the following resources:\n\n- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.\n- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.\n\nYou can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefinitelynotchirag%2Fauth-nextjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdefinitelynotchirag%2Fauth-nextjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefinitelynotchirag%2Fauth-nextjs/lists"}