Modified form Prisma Examples
This example shows how to implement a fullstack app in TypeScript with Next.js using React and Prisma Client.
- Create a TiDB Cloud account and get your free trial cluster.
- Navigate to your TiDB Serverless cluster's dashboard.
- Get Endpoint, Port and User field from the Connection tab.
- Build your DATABASE_URL string:
mysql://<User>:<Password>@<Endpoint>:<Port>/bookshop
You will use this DATABASE_URL string to connect to TiDB Serverless cluster later.
- Clone the code.
git clone https://github.com/tidbcloud/nextjs-prisma-example.git cd nextjs-prisma-example
- Set DATABASE_URL environment variables.
export DATABASE_URL=${your_DATABASE_URL_string}
- Install dependence.
npm install .
- Migrate your database.
prisma migrate dev
- Start the project.
npm run dev
### 🧑🍳 Before We Start
- Create a TiDB Cloud account and get your free trial cluster.
- Create a Netlify account.
- Navigate to your TiDB Serverless cluster's dashboard.
- Get Endpoint, Port and User field from the Connection tab.
- Build your DATABASE_URL string:
mysql://<User>:<Password>@<Endpoint>:<Port>/bookshop
You will use this DATABASE_URL string to connect to TiDB Serverless cluster later.
The Deploy to Netlify button will take you Netlify's deployment page. Then Netlify will help to clone this job to your own GitHub repository and automatically deploy it.
- Click the Deploy to Netlify button.
- Click Connect to GitHub and authenticate GitHub account.
- Fill in Repository name for your own GitHub repository.
- Click Save & Deploy.
- Navigate to Site setting panel.
- Click Add a variable in the Environment variables sidebar.
- Enter "DATABASE_URL" in the Key field.
- Enter the DATABASE_URL string, set in the previous step, in the Values field.
- Click Create variable to complete adding environment variable.
- Navigate to Deploys panel.
- Click Trigger deploy and choose Deploy site.
🎉 Mission Completes.
Now you can view your site on default domain generated by Netlify.