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.schemaFor Next.js projects
bun add @contractspec/lib.contractsFor database models
bun add @contractspec/app.cli-database prisma @prisma/clientSet up your project
Initialize a new ContractSpec project structure:
installation-init
bunx contractspec init
# Follow the interactive prompts to configure your projectInitialize 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