Skip to main content

Basic Usage

After running bunx 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 named config:
ReadOnly generates this type:

IntelliSense

Your editor will provide:
  • Auto-completion for all properties
  • Type checking
  • Inline documentation
  • Go-to-definition support
IntelliSense example

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:
When you update files in the dashboard, they’ll sync automatically.

Production

Run watch mode alongside your app:
package.json

Best Practices

Individual files are limited to 10MB. Keep files focused and avoid large datasets.
Name your files descriptively: config, features, redirects, not data1, file2.
Ensure your JSON is valid and follows a consistent structure. ReadOnly validates JSON objects only (no arrays or primitives at root).
Always run readonly sync before building for production to ensure files are up-to-date.
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.