Installation
Install Dependencies
Using pnpm:
pnpm installOr using npm:
npm installOr using Yarn:
yarn installEnvironment Variables
Create a .env.local file in the root directory by copying the example:
cp .env.dist .env.localGenerate Auth Secret
- Generate the
AUTH_SECRETvariable using the following command:
npx auth secretIt should automatically add the secret to your .env.local file:
AUTH_SECRET=your_generated_auth_secretGenerate Encryption Key for Passwords
- Run the following command to generate an encryption key:
openssl rand -base64 32- Add the generated key to your
.envfile:
ENCRYPTION_KEY=your_generated_keyConfigure Password Salt Rounds
-
Choose a Salt Rounds Value: Decide on the number of salt rounds for hashing passwords. A minimum of 10 is recommended for security.
-
Add to Environment File: Add the chosen number of salt rounds to your
.env.localfile:
PASSWORD_SALT_ROUNDS=your_chosen_numberDatabase Setup
- Install dotenv-cli
First, install dotenv-cli globally as it's required for database commands:
pnpm add -g dotenv-cli- Configure Database URL
Ensure your .env.local file has the correct DATABASE_URL. For example:
DATABASE_URL="postgresql://user:password@localhost:5432/mydb?schema=public"- Run Migrations
Apply database migrations in development:
pnpm migrate:dev- Run Seeds (Optional)
After running migrations, you can optionally run seeds to populate your database with initial data:
pnpm db:seed- Update Prisma Client
Whenever you make changes to schema.prisma, regenerate the Prisma Client with:
npx prisma generateWhat It Does:
- Reads Your Prisma Schema: The command looks at your
schema.prismafile. - Generates Prisma Client: Based on the schema, it generates the Prisma Client code.
- Type-Safety and Autocompletion: The generated client is fully typed based on your schema.
Running the Project
Start the development server:
pnpm devOr using npm:
npm run devOr using Yarn:
yarn devOpen http://localhost:3000 in your browser to see the application.