accelerant
v0.2.0
Published
A service worker for simplifying your frontend integration with Firebase
Downloads
586
Maintainers
Readme
Accelerant
Accelerant exposes Firebase Auth, Firestore, and Storage through a service worker API so your frontend can use fetch without importing the Firebase SDK.
Usage
App (register the service worker)
import { registerServiceWorker } from 'accelerant';
await registerServiceWorker({
// TBD
});Service worker
import { registerRoutes } from 'accelerant/sw';
registerRoutes({
firebaseConfig: {
apiKey: '...'
// other firebase config fields
},
apiPrefix: '/api',
requireClaims: { admin: true }
});Auth claim requirements
The requireClaims option controls which custom claims a user must have to sign in.
Accepted forms:
- Object:
{ admin: true, tier: 'pro' } - Array:
['admin', 'beta'](equivalent to alltrue)
If requireClaims is omitted or null, any valid user can sign in.
Development setup
Install uv and Node.js (v22+), then:
# Install JS dependencies
pnpm install
# Install and register pre-commit hooks
uv tool install prek
prek installAfter setup, commits will automatically run Biome (lint + format). If Biome modifies any files, the commit is blocked — review the diff, git add the changes, and commit again.
Lint and format
pnpm lint # check only
pnpm lint:fix # check and auto-fix
pnpm format # format onlyE2E testing
E2E uses Playwright + Vite and runs against Firebase emulators.
Install dependencies and browsers:
pnpm install
pnpm exec playwright installRun the automated E2E suite:
pnpm test:e2eOpen the manual test page:
pnpm exec vite --config test/e2e/vite.config.jsThen visit http://localhost:4173 and use the buttons to exercise Auth/Firestore/Storage.
