Installation

Add ContractSpec to your existing Next.js or Bun project, or start fresh.

Prerequisites

  • Node.js 20+ (or Bun 1.0+)
  • Existing Next.js app or Bun HTTP server
  • PostgreSQL database (for persistence)

Install Core Libraries

Add the contracts runtime and your choice of adapter:

bun add @contractspec/lib.contracts @contractspec/lib.schema

For Next.js projects

bun add @contractspec/lib.contracts

For database models

bun add @contractspec/app.cli-database prisma @prisma/client

Set up your project

Initialize a new ContractSpec project structure:

installation-init
bunx contractspec init
# Follow the interactive prompts to configure your project

Initialize the database

If using Prisma, set up your schema and generate the client:

installation-prisma
bunx prisma init
# Edit prisma/schema.prisma with your models
bunx prisma generate
bunx prisma migrate dev --name init