Basic Usage
After runningbunx readonly sync, your files are available for import:
All imports are fully typed with IntelliSense support!
Type Safety
ReadOnly automatically generates TypeScript types by introspecting your JSON files.Example
Given this JSON file namedconfig:
IntelliSense
Your editor will provide:- Auto-completion for all properties
- Type checking
- Inline documentation
- Go-to-definition support

Import Patterns
Named Imports
Import specific files:Wildcard Import
Import all files at once:Re-exporting
Re-export for use throughout your app:Common Use Cases
1. Configuration
Store app configuration in ReadOnly:2. Content Management
Manage blog posts or documentation:3. Redirects
Handle URL redirects:4. Feature Flags
Manage feature flags:5. Reference Data
Store reference data like countries, currencies, etc:Framework Examples
Next.js
Express
Remix
Astro
Runtime vs Build Time
Runtime Loading
Files are loaded at runtime from the cache:Build Time Sync
Sync during build to include files in your bundle:package.json
File Updates
Development
Use watch mode to automatically sync updates:Production
Run watch mode alongside your app:package.json
Best Practices
Keep files small
Keep files small
Individual files are limited to 10MB. Keep files focused and avoid large datasets.
Use descriptive names
Use descriptive names
Name your files descriptively:
config, features, redirects, not data1, file2.Validate JSON structure
Validate JSON structure
Ensure your JSON is valid and follows a consistent structure. ReadOnly validates JSON objects only (no arrays or
primitives at root).
Sync before build
Sync before build
Always run
readonly sync before building for production to ensure files are up-to-date.Use watch mode in development
Use watch mode in development
Run
readonly dev alongside your dev server to automatically sync changes.Next Steps
CLI Reference
Learn about all available commands.
Configuration
Customize cache and output directories.
Installation
Installation and setup guide.
Troubleshooting
Common issues and solutions.