Skip to content

cipherstash/example-protect-next-drizzle-mysql

Repository files navigation

Next.js + Drizzle ORM + MySQL + Protect.js Example

This example demonstrates how to build a modern web application using:

  • Next.js - React framework for production
  • Drizzle ORM - TypeScript ORM for SQL databases
  • MySQL - Popular open-source relational database
  • Protect.js - Data protection and encryption library

Features

  • Full-stack TypeScript application
  • Database migrations and schema management with Drizzle
  • Data protection and encryption with Protect.js
  • Modern UI with Tailwind CSS
  • Form handling with React Hook Form and Zod validation
  • Docker-based MySQL database setup

Prerequisites

  • Node.js 18+
  • Docker and Docker Compose
  • MySQL (if running locally without Docker)

Getting Started

  1. Clone the repository and install dependencies:

    npm install
  2. Set up your environment variables: Copy the .env.example file to .env.local:

    cp .env.example .env.local

    Then update the environment variables in .env.local with your Protect.js configuration values.

  3. Start the MySQL database using Docker:

    docker-compose up -d
  4. Run database migrations:

    npm run db:generate
    npm run db:migrate
  5. Start the development server:

    npm run dev

The application will be available at http://localhost:3000.

Project Structure

  • /src - Application source code
  • /drizzle - Database migrations and schema
  • /public - Static assets
  • drizzle.config.ts - Drizzle ORM configuration
  • docker-compose.yml - Docker configuration for MySQL

Available Scripts

  • npm run dev - Start development server
  • npm run build - Build for production
  • npm run start - Start production server
  • npm run db:generate - Generate database migrations
  • npm run db:migrate - Run database migrations

Learn More

About

Next.js + Drizzle ORM + MySQL + Protect.js Example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published