This is a Next.js project bootstrapped with create-next-app. It demonstrates a simple full-stack CRUD application using Next.js 14, PostgreSQL, and Prisma.
First, clone the repository and install the dependencies:
git clone https://github.com/KleitonEwerton/to-learn-nextjs.git
cd to-learn-nextjs
yarn install
or
yarn install
Then, run the development server:
npm run dev
yarn dev
Open http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.
This project uses next/font to automatically optimize and load Inter, a custom Google Font.
This project uses PostgreSQL as its database. To get started, you can run a PostgreSQL instance with Docker:
docker-compose up -d
Alternatively, if you prefer using a local PostgreSQL instance, edit the .env file and update the DATABASE_URL with a valid PostgreSQL connection string:
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgresnest"
To set up Prisma, follow these steps:
-
Initialize Prisma:
npx prisma init
-
Generate Prisma client:
npx prisma generate
-
Run migrations:
bash npx prisma migrate dev
Prisma will use the connection string specified in the DATABASE_URL environment variable.
The following scripts are available in the project:
- npm run dev - Runs the application in development mode.
- npm run build - Builds the application for production.
- npm run start - Starts the application in production mode.
- npm run lint - Runs ESLint to check for linting errors.
Next.js
- A React framework for production.React
- A JavaScript library for building user interfaces.Prisma
- Next-generation ORM for Node.js and TypeScript.PostgreSQL
- A powerful, open-source object-relational database system.Tailwind CSS
- A utility-first CSS framework for rapid UI development.Zod
- A TypeScript-first schema declaration and validation library.