Skip to content

Latest commit

 

History

History

starter

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Prisma Optimize starter example

This example shows the basics of Prisma Optimize in a Todo app. It uses a SQLite database file with some initial dummy data which you can find at ./prisma/dev.db.

Getting started

1. Download example and install dependencies

Download this example:

npx try-prisma@latest --template optimize/starter

Install npm dependencies:

cd starter
npm install
Alternative: Clone the entire repo

Clone this repository:

git clone [email protected]:prisma/prisma-examples.git --depth=1

Install npm dependencies:

cd prisma-examples/optimize/optimize_starter
npm install

2. Create the database

Run npm run build from project root to create your SQLite database.

3. Log in to Optimize

Login and create an API key (also called a token) in the Optimize dashboard.

Navigate to packages/server and add a .env file that matches the .env.example file.

cd packages/server
cp .env.example .env

Copy your API key (also called token) to the PRISMA_OPTIMIZE_TOKEN.

PRISMA_OPTIMIZE_TOKEN="<your_token_here>"

4. Run the app

  1. Got to recordings in the Optimize dashboard and click the "Start recording" button.
  2. Run npm start from the project root.
  3. Open the demo app @ http://localhost:5173 in the browser. Perform a bunch of actions - add a Todo, mark a Todo as complete, delete a Todo, etc.
  4. Go back to the Optimize dashboard and click the "Stop recording" button.
  5. Enjoy some sweet queries, groups, and most importantly recommendations with our friendly AI chat.

Next steps