This is a Next.js project that uses Prisma
- Node.js
winget install --id OpenJS.NodeJS.LTS
on Windows - NPM
- a MariaDB or MySQL database
git clone 'https://github.com/OrifInformatique/Nextjs_test.git'
cd Nextjs_test
npm install
create a .env.local file
touch .env.local
and put it in the URL of the API
NEXT_PUBLIC_API_URL=http://localhost:3000/api
Create a new database with the following command:
mariadb -u root -p <<< 'CREATE DATABASE db20230815'
First, create your .env
file by renaming the .env.example
file to .env
:
cp .env.example .env
to put in .env
mysql://<USERNAME>:<PLAIN_TEXT_PASSWORD>@<ACCESS_HOST_URL>/<DATABASE_NAME>?sslaccept=strict
Example with the database of xampp on windows11 (here the database names db20230815)
DATABASE_URL=mysql://root@localhost/db20230815
Push the database schema
npx prisma db push
Run the seed script to populate your database with Product
and Category
data.
npm run seed
Run the app with following command:
npm run dev
Open your browser at localhost:3000 to see the running application.
for npx prisma db push
with Error: Unknown binaryTarget debian-openssl-3.0.x and no custom binaries were provided
output:
npm install prisma --save-dev
npm install @prisma/client@dev prisma@dev