DEV Community

Mikhael Esa
Mikhael Esa

Posted on

2

Building a Fullstack Application With Next.js + Prisma + SQLite

TL;DR

My first thought on Next.js was "Oh it's just another front-end framework based on React" but I was wrong. Next.js is not just another front-end framework but it is a fullstack framework. Yes you heard it right, fullstack.

Mindblown Gif

I have done some research about this topic and these 3 stacks suits me well for building a simple fullstack app. And I was blown away by how these 3 tech has a rich feature and gives me a huge boost in Developer Experience.

References

If you are interested in reading the documentation of each technology, then here's the link to the documentations:

Now let's go get our hands dirty.

Dirty Hands Gif

Project Setup

First let's go with installing a fresh next.js app with this command.

$ npx create-next-app@latest
Enter fullscreen mode Exit fullscreen mode

Then you can just answer the prompts but when it prompt you to use an App router, choose no as we are going to use the OG pages router 😉.

Next, we are going to setup the prisma so let's install prisma.

npm i -D prisma
Enter fullscreen mode Exit fullscreen mode

After installing we will initialize prisma preconfigured with sqlite by running this command.

$ npx prisma init --datasource-provider sqlite
Enter fullscreen mode Exit fullscreen mode

It will generate a prisma folder with schema.prisma file init. We will put our models inside the file so let's create some models

model User {
  id    Int     @id @default(autoincrement())
  email String  @unique
  name  String?
  posts Post[]
}

model Post {
  id        Int     @id @default(autoincrement())
  title     String
  content   String?
  published Boolean @default(false)
  author    User    @relation(fields: [authorId], references: [id])
  authorId  Int
}
Enter fullscreen mode Exit fullscreen mode

We have created 2 models which are User and Post where these 2 models has relation to each other.

We have models, now we have to create the DB in order to do CRUD.

$ npx prisma migrate dev --name init
Enter fullscreen mode Exit fullscreen mode

It will create a migration folder inside the prisma folder.

Great! Now you have a database already setup. Next step is to create an API to do CRUD.

ACI image

ACI.dev: The Only MCP Server Your AI Agents Need

ACI.dev’s open-source tool-use platform and Unified MCP Server turns 600+ functions into two simple MCP tools on one server—search and execute. Comes with multi-tenant auth and natural-language permission scopes. 100% open-source under Apache 2.0.

Star our GitHub!

Top comments (0)

Image of Timescale

PostgreSQL for Agentic AI — Build Autonomous Apps on One Stack ☝️

pgai turns PostgreSQL into an AI-native database for building RAG pipelines and intelligent agents. Run vector search, embeddings, and LLMs—all in SQL

Build Today

👋 Kindness is contagious

Delve into this thought-provoking piece, celebrated by the DEV Community. Coders from every walk are invited to share their insights and strengthen our collective intelligence.

A heartfelt “thank you” can transform someone’s day—leave yours in the comments!

On DEV, knowledge sharing paves our journey and forges strong connections. Found this helpful? A simple thanks to the author means so much.

Get Started