[!CAUTION] The maintainer of the Lucia authentication library has announced plans to deprecate it early next year. Due to the library's limitations and complexity, particularly around database adapters, the maintainer has decided to shift focus to providing Lucia as an open-source resource for learning how to implement authentication and sessions from scratch. This new direction will include tutorials and examples for advanced features like 2FA, password reset, and rate limiting, while the Discord server will continue to offer general auth support. The current version of Lucia (v3) will be maintained for another six months (early 2025), with some adapters possibly deprecated sooner. lucia-auth discussions #1707
[!TIP]
Use this New Template with Better Auth instead of Lucia Auth.
Welcome to the Next.js Drizzle MySQL Tailwind Lucia Template! This template offers a comprehensive starting point for building web applications using cutting-edge technologies like Next.js, Drizzle ORM, MySQL, Tailwind CSS, @tanstack/react-query, and Lucia.
Experience the live demo of this template deployed on Vercel: Next.js Drizzle MySQL Tailwind Demo.
For the database, this template uses MySQL. You can configure any database you want. Refer to the Drizzle Documentation for more details.
Get up and running quickly by following these steps:
Ensure you have the following installed:
Start by cloning the repository to your local machine:
git clone https://github.com/Its-Satyajit/nextjs-drizzle-mysql-tailwind.git
Move into the project directory:
cd nextjs-drizzle-mysql-tailwind
Install the necessary dependencies using your preferred package manager:
npm install
pnpm install
yarn install
bun install
Configure your database by adding credentials to the .env
file. Then, generate and migrate your database schema:
npm run dk:gen
npm run dk:mig
pnpm run dk:gen
pnpm run dk:mig
yarn run dk:gen
yarn run dk:mig
bun run dk:gen
bun run dk:mig
Once everything is set up, start the development server:
npm run dev
pnpm run dev
yarn run dev
bun run dev
Note: If you're using Bun and encounter any issues, please refer to Bun's documentation as some commands may differ.
This template includes a set of scripts to streamline your development process:
dev-t
: Start the development server with the Next.js Turbopack bundler.dev
: Start the development server.build
: Build the application for production.start
: Start the application in production mode.lint
: Run ESLint for code linting.dk:gen
: Generate Drizzle ORM files for MySQL.dk:push
: Push changes to the MySQL database using Drizzle ORM.dk:pull
: Introspect the MySQL database using Drizzle ORM.dk:stdio
: Launch Drizzle Kit Studio with verbose output.dk:mig
: Run database migrations.dk:introspect
: Introspect the database schema.These scripts cover essential tasks during development and deployment.
The project's structure is thoughtfully organized to support efficient development:
root ├───drizzle │ └───meta ├───node_modules ├───public └───src ├───actions ├───app │ └───(auth) │ ├───signin │ └───signup ├───auth ├───components │ └───forms └───db └───schema
Feel free to adapt the project structure to meet the specific needs of your application.
This template leverages a robust set of dependencies to deliver high performance and scalability:
For a smooth development experience, the following tools and libraries are included:
npm run dev-t
) for faster builds during development.zustand
for scalable and efficient state management.This project is licensed under the MIT License. For more details, please refer to the LICENSE file.