{"id":25586,"library":"firebase-bolt","title":"Firebase Bolt Compiler","description":"An experimental security and modeling language compiler for Firebase Realtime Database (not Cloud Storage). Compiles .bolt files into Firebase security rules JSON. Current version 0.8.4, in beta, with typescript declarations added in 0.8.3. Key differentiator: acts as a DSL for Firebase security rules, offering type validation, path templates, and schema modeling to reduce manual rules authoring. Alternates like hand-writing JSON or using other rule generators are less expressive.","status":"active","version":"0.8.4","language":"javascript","source_language":"en","source_url":"https://github.com/firebase/bolt","tags":["javascript","firebase","security","rules","schema","models","blaze","typescript"],"install":[{"cmd":"npm install firebase-bolt","lang":"bash","label":"npm"},{"cmd":"yarn add firebase-bolt","lang":"bash","label":"yarn"},{"cmd":"pnpm add firebase-bolt","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is ESM-only. Use named imports, not default imports or require.","wrong":"const compile = require('firebase-bolt')","symbol":"compile","correct":"import { compile } from 'firebase-bolt'"},{"note":"Use named import 'compileRules' directly from the package root.","wrong":"import { compile } from 'firebase-bolt/compile'","symbol":"compileRules","correct":"import { compileRules } from 'firebase-bolt'"},{"note":"RuleSet is a type and should be imported with `import type` in TypeScript.","wrong":"import { RuleSet } from 'firebase-bolt'","symbol":"type RuleSet","correct":"import type { RuleSet } from 'firebase-bolt'"}],"quickstart":{"code":"import { compileRules } from 'firebase-bolt';\nconst boltCode = `\n  path / {\n    read() { true }\n    write() { auth != null }\n  }\n  type User {\n    name: String,\n    age: Number\n  }\n  path /users/$uid is User {\n    read() { true }\n    write() { $uid === auth.uid }\n  }\n`;\nconst rules = compileRules(boltCode);\nconsole.log(JSON.stringify(rules, null, 2));\n// Output: {\"rules\":{\".read\":\"true\",\".write\":\"auth != null\",\"users\":{\"$uid\":{\".validate\":\"newData.hasChildren(['name','age'])\",\".read\":\"true\",\".write\":\"$uid === auth.uid\"}}}}","lang":"typescript","description":"Compiles a security rules Bolt snippet to JSON using compileRules."},"warnings":[{"fix":"Replace wildcard variables (e.g., $uid) with path templates (e.g., /users/$uid) in path definitions.","message":"Path expressions now use path template syntax instead of wildcard variables.","severity":"breaking","affected_versions":">=0.7.0"},{"fix":"Use modern function syntax: fn(x) { exp }.","message":"Function definition format fn(x) = exp; is deprecated.","severity":"deprecated","affected_versions":">=0.7.0"},{"fix":"Do not use for Firestore security rules. Use Firebase CLI's built-in rules languages instead.","message":"Bolt only supports Firebase Realtime Database, not Cloud Firestore or Cloud Storage.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Review rules.json output manually or test in Firebase console.","message":"Hand-verify generated JSON rules before production use; compiler is experimental.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure your Firebase Realtime Database version supports these aliases, or use write() directly.","message":"The create()/update()/delete() aliases for write() may not be recognized in older Firebase versions.","severity":"gotcha","affected_versions":">=0.8.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use named import: import { compileRules } from 'firebase-bolt'.","cause":"Attempting to import with default import (import bolt from 'firebase-bolt') or require syntax.","error":"Error: The module 'firebase-bolt' does not export a default."},{"fix":"Use compileRules instead of compile. The correct named export is compileRules.","cause":"Using wrong import name (compile vs compileRules).","error":"TypeError: bolt.compile is not a function"},{"fix":"Review your Bolt syntax. Ensure functions use modern syntax: read() { true } not read() true.","cause":"Using deprecated function syntax or incorrect path template, typically missing parentheses or braces.","error":"ParseError: Expected ( but got something else (line 5, col 20)"},{"fix":"Run `npm install firebase-bolt` in your project directory, or install globally with `npm install -g firebase-bolt`.","cause":"Package not installed locally or globally.","error":"Error: Cannot find module 'firebase-bolt'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}