Skip to content

siddontang/next-tidb-demo

Repository files navigation

Next.js + TiDB

This is a Next.js project that uses TiDB as a database and OSS Insight as a data source.

The online demo is next-tidb-demo.vercel.app, hosted by Vercel and TiDB Cloud.

Getting Started

Use a TiDB Cloud Developer Tier (Free)

  • Visit TiDB Cloud and do the Sign Up.
  • Create a Developer Tier (Free).
  • Click your cluster name in Active Cluster page, and then Click the Connect button, and get the connection Endpoint.

Load Sample Data

Follow the guide to load OSS Insight sample data into TiDB cloud.

Start the Server

Set environment variables

export MYSQL_HOST=tidb.6479717b.c3f4522.ap-northeast-1.prod.aws.tidbcloud.com 
export MYSQL_PORT=4000 
export MYSQL_USER=root 
export MYSQL_DATABASE=gharchive_dev
export MYSQL_PASSWORD={your password}

Run the development server:

npm run dev
# or
yarn dev

Open http://localhost:3000 with your browser to see the result.

Learn More

To learn more about Next.js + TiDB, take a look at the following resources:

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.