Install CopyPatch v3
CopyPatch packages are published under the @copypatch npm scope. Install only the packages required for your client and server architecture.
Prerequisites
- Runtime: Node.js
>=20.0.0(Node.js 24 LTS recommended) - Module Format: Pure ESM (ECMAScript Modules)
- Peer Dependencies: React and React DOM
>=18 <20 - Environment: Server-capable host application with same-origin routing
Package Ecosystem
| Package | Target Environment | Description |
|---|---|---|
@copypatch/core | Universal (Browser & Server) | Types, schema validation, string normalizers, and API constants. |
@copypatch/react | Browser (React) | CopyPatchProvider, EditableText, React hooks, and lazy editor UI. |
@copypatch/backend | Node Server | Embedded Web Request/Response API runtime, Argon2id auth, and CSRF protection. |
@copypatch/storage-sqlite | Node Server | Transactional SQLite storage adapter with atomic compare-and-swap revisions. |
@copypatch/storage-postgres | Node Server | Connection-pooled PostgreSQL storage adapter for distributed instances. |
@copypatch/node | Node Server & CLI | Native Node HTTP, Express, Fastify, Hono middleware, and the copypatch CLI. |
@copypatch/next | Next.js App Router | Same-origin route handlers, server component snapshot reader, and Next.js provider. |
Installing Dependencies
Terminal (pnpm)
# Core & React Client
pnpm add @copypatch/core @copypatch/react
# Embedded Backend & SQLite Storage
pnpm add @copypatch/backend @copypatch/storage-sqlite
# Framework Adapters (Choose your host)
pnpm add @copypatch/next # For Next.js App Router
pnpm add @copypatch/node # For Astro, Express, Fastify, Hono, React RouterTerminal (npm)
npm install @copypatch/core @copypatch/react @copypatch/backend @copypatch/storage-sqlite @copypatch/node @copypatch/nextCLI Scaffolding & Utility Commands
The @copypatch/node package includes the official copypatch CLI to scaffold configuration files, hash passphrases, and run migrations:
CLI Commands
# Interactive scaffolding (or provide explicit flags)
npx copypatch init --framework next --storage sqlite
# Test scaffolding without writing files
npx copypatch init --framework next --storage sqlite --dry-run
# Generate secure Argon2id passphrase hash
printf 'your-secure-passphrase' | npx copypatch hash --stdin
# Apply database schema migrations
npx copypatch migrate --storage sqlite
# Verify runtime configuration and health
npx copypatch doctorCLI Command Reference
| Command | Flags | Purpose |
|---|---|---|
copypatch init | –framework <next|astro|react-router|vite-node>–storage <sqlite|postgres>–dry-run, –cwd <dir> | Generates the configuration and route files, adds their direct dependencies to the host package.json, and prints the detected install command without running it. Safe to re-run; never overwrites conflicting files. |
copypatch hash | –stdin, –passphrase <str> | Generates a cryptographically secure Argon2id hash. Using –stdin prevents exposing secrets in shell history. |
copypatch migrate | –storage <sqlite|postgres> | Executes idempotent database schema migrations. |
copypatch doctor | None | Inspects the generated configuration and required CopyPatch environment variables. |
Note: The CopyPatch CLI intentionally does not have a
servecommand. CopyPatch is embedded into your application’s existing HTTP server instead of running as a separate daemon.