Snaplet is an all-in-one developer tool that gives developers realistic, production-like data to code against. It solves the common problem developers face when working with databases - having safe, realistic data without exposing sensitive production information.
- πΈ Database Snapshots: Capture and transform data from your production database
- π Data Privacy: Automatically detect and transform PII with built-in anonymization
- π― Data Subsetting: Capture only the data you need while maintaining referential integrity
- π Fast Restoration: Quickly restore snapshots to your development database
- π οΈ TypeScript Configuration: Type-safe configuration with full IDE support
- π Self-Hostable: Run on your own infrastructure for complete control
- π Database Agnostic: Works with PostgreSQL (more databases coming soon)
- Node.js v18.18.2 or higher
- PostgreSQL database (for capturing/restoring snapshots)
- npm, yarn, or pnpm package manager
# Using npm
npm install -g @snaplet/snapshot
# Using yarn
yarn global add @snaplet/snapshot
# Using pnpm
pnpm add -g @snaplet/snapshot
- Setup Snaplet in your project
snaplet setup
This will create a snaplet.config.ts
file in your project root.
- Capture a snapshot from your database
# Capture from your production database
snaplet snapshot capture --db-url postgresql://user:pass@host:5432/mydb
# Or use environment variables
DATABASE_URL=postgresql://... snaplet snapshot capture
- List available snapshots
snaplet snapshot list
- Restore a snapshot to your development database
# Restore the latest snapshot
snaplet snapshot restore --latest
# Restore a specific snapshot
snaplet snapshot restore <snapshot-id>
Snaplet uses a TypeScript configuration file (snaplet.config.ts
) for advanced features:
import { defineConfig } from '@snaplet/sdk'
import { copycat } from '@snaplet/copycat'
export default defineConfig({
// Select which schemas to include
select: {
public: {
// Include all tables except 'logs'
$default: true,
logs: false,
}
},
// Transform sensitive data
transform: {
public: {
users: ({ row }) => ({
email: copycat.email(row.email),
name: copycat.fullName(row.name),
phone: copycat.phoneNumber(row.phone),
}),
}
},
// Data subsetting
subset: {
enabled: true,
version: '3',
targets: [
{
table: 'public.users',
percent: 10, // Capture only 10% of users
}
]
}
})
Create safe development databases with production-like data:
# Capture a subset of production data
snaplet snapshot capture --db-url $PROD_DB_URL
# Restore to local development
snaplet snapshot restore --db-url postgresql://localhost:5432/dev_db
Use snapshots in your CI pipeline:
# .github/workflows/test.yml
steps:
- uses: actions/checkout@v3
- name: Restore test database
run: snaplet snapshot restore --latest
- name: Run tests
run: npm test
Transform PII automatically during capture:
// snaplet.config.ts
export default defineConfig({
transform: {
$mode: 'auto', // Automatically detect and transform PII
}
})
snaplet setup
- Initialize Snaplet in your projectsnaplet snapshot capture
- Create a database snapshotsnaplet snapshot list
- List available snapshotssnaplet snapshot restore
- Restore a snapshotsnaplet config generate
- Generate configuration files
--db-url
- Database connection string--latest
- Use the latest snapshot--yes
- Skip confirmation prompts--verbose
- Enable verbose logging
Run snaplet --help
for a complete list of commands and options.
Visit our documentation for:
We welcome contributions! Please see our Contributing Guide for details on:
- Setting up your development environment
- Running tests
- Submitting pull requests
- Code style guidelines
- π¬ Join our Discord - Get help and chat with the community
- π Report Issues - Found a bug? Let us know!
- π§ Email Support - For sensitive issues or enterprise inquiries
Snaplet is licensed under the Functional Source License (FSL-1.1-MIT). See the LICENSE file for details.
After 2 years, the license automatically converts to MIT.
Snaplet is built on top of many amazing open-source projects including:
- PostgreSQL - The world's most advanced open source database
- TypeScript - JavaScript with syntax for types
- Turborepo - High-performance build system for JavaScript and TypeScript
- And many more wonderful projects!