Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/saasykits/next-lucia-auth
This is a Next.js T3 project with authentication implemented using Lucia.
https://github.com/saasykits/next-lucia-auth
drizzle-auth lucia-auth nextjs-auth-example nextjs-auth-reset nextjs-role-based-access-policy nextjs-user-verification t3-stack trpc trpc-with-lucia
Last synced: about 1 month ago
JSON representation
This is a Next.js T3 project with authentication implemented using Lucia.
- Host: GitHub
- URL: https://github.com/saasykits/next-lucia-auth
- Owner: saasykits
- License: mit
- Created: 2023-12-27T17:00:33.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-08-17T09:53:40.000Z (3 months ago)
- Last Synced: 2024-09-27T12:42:18.555Z (about 2 months ago)
- Topics: drizzle-auth, lucia-auth, nextjs-auth-example, nextjs-auth-reset, nextjs-role-based-access-policy, nextjs-user-verification, t3-stack, trpc, trpc-with-lucia
- Language: TypeScript
- Homepage: https://next-lucia.vercel.app
- Size: 504 KB
- Stars: 462
- Watchers: 5
- Forks: 57
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Next.js Auth Starter Template
## Motivation
Implementing authentication in Next.js, especially Email+Password authentication, can be challenging. NextAuth intentionally limits email password functionality to discourage the use of passwords due to security risks and added complexity. However, in certain projects, clients may require user password authentication. Lucia offers a flexible alternative to NextAuth.js, providing more customization options without compromising on security. This template serves as a starting point for building a Next.js app with Lucia authentication.
## Lucia vs. NextAuth.js
Lucia is less opinionated than NextAuth, offering greater flexibility for customization. While Lucia involves more setup, it provides a higher degree of flexibility, making it a suitable choice for projects requiring unique authentication configurations.
## Key Features
- **Authentication:** ๐ผ Support for Credential and OAuth authentication.
- **Authorization:** ๐ Easily manage public and protected routes within the `app directory`.
- **Email Verification:** ๐ง Verify user identities through email.
- **Password Reset:** ๐ Streamline password resets by sending email password reset links.
- **Lucia + tRPC:** ๐ Similar to NextAuth with tRPC, granting access to sessions and user information through tRPC procedures.
- **E2E tests:** ๐งช Catch every issue before your users do with comprehensive E2E testing.
- **Stripe Payment:** ๐ณ Setup user subscriptions seamlessly with stripe.
- **Email template with react-email:** โ๏ธ Craft your email templates using React.
- **PostgreSQL Database:** ๐ข๏ธ Utilize a PostgreSQL database set up using Drizzle for enhanced performance and type safety.
- **Database Migration:** ๐ Included migration script to extend the database schema according to your project needs.## Tech Stack
- [Next.js](https://nextjs.org)
- [Lucia](https://lucia-auth.com/)
- [tRPC](https://trpc.io)
- [Drizzle ORM](https://orm.drizzle.team/)
- [PostgreSQL](https://www.postgresql.org/)
- [Stripe](https://stripe.com/)
- [Tailwind CSS](https://tailwindcss.com)
- [Shadcn UI](https://ui.shadcn.com/)
- [React Hook Form](https://www.react-hook-form.com/)
- [React Email](https://react.email/)
- [Playwright](https://playwright.dev/)## Get Started
1. Clone this repository to your local machine.
2. Copy `.env.example` to `.env` and fill in the required environment variables.
3. Run `pnpm install` to install dependencies.
4. `(for node v18 or lower):` Uncomment polyfills for `webCrypto` in `src/lib/auth/index.ts`
5. Update app title, database prefix, and other parameters in the `src/lib/constants.ts` file.
6. Run `pnpm db:push` to push your schema to the database.
7. Execute `pnpm dev` to start the development server and enjoy!## Testing
1. Install [Playwright](https://playwright.dev/) (use this command if you want to install chromium only `pnpm exec playwright install chromium --with-deps`)
2. Build production files using `pnpm build`
3. Run `pnpm test:e2e` (add --debug flag to open tests in browser in debug mode)## Using Github actions
Add the following environment variables to your **github actions repository secrets** -
`DATABASE_URL`, `DISCORD_CLIENT_ID`, `DISCORD_CLIENT_SECRET`## Roadmap
- [ ] Update Password
- [x] Stripe Integration- [ ] Admin Dashboard (under consideration)
- [ ] Role-Based Access Policy (under consideration)## Contributing
To contribute, fork the repository and create a feature branch. Test your changes, and if possible, open an issue for discussion before submitting a pull request. Follow project guidelines, and welcome feedback to ensure a smooth integration of your contributions. Your pull requests are warmly welcome.