Skip to content
On this page

Development

To begin development, you'll need a copy of the code and a local database. The easiest way to get started is via a SQLite DB file. That's what we'll be doing here:

1. Clone the repository

bash
git clone https://github.com/ndom91/briefkasten
cd briefkasten
1
2

2. Install dependencies

bash
pnpm install
1

3. Setup your environment variables

bash
cp .env.example .env
vim .env
1
2

Now that you have the .env file open in an editor, you'll want to modify at least the following values:

VariableValue
DATABASE_URLfile:./dev.db
NEXTAUTH_URLSet to your current local development URL (i.e. http://localhost:3000)
NEXTAUTH_SECRETSet to the output of openssl rand -hex 32

INFO

You'll also need to change another line in the prisma/schema.prisma file. To use a local SQLite database file, you'll want the datasource section of the Prisma schema file to look something like this.

prisma
datasource db {
  provider = "sqlite"
  url      = env("DATABASE_URL")
}
1
2
3
4

In addition, to use a SQLite database, you'll have to remove the @db.Text annotations in the schema.prisma file, as that is Postgres specific.

You can do this with one command like so: sed -i 's/@db.Text//g' prisma/schema.prisma

If you want to setup any OAuth login provider, you'll also want to add either the GITHUB_ID/GITHUB_SECRET or the Google keys. Please see the NextAuth.js docs for more details on how exactly to set that up.

4. Bring up the database and run migrations

bash
pnpm dlx prisma migrate dev
# or
npx prisma migrate
1
2
3

5. Start the development server

Once you've got the database prepared and all dependencies installed, we can start the dev server!

bash
pnpm dev
1

TIP

Prisma comes with a little development database viewer, which I've setup under the npm script db:studio, meaning you can start it by running:

bash
pnpm db:studio
1