Metabase Local Testing - Quick Start
π Quick Start (5 minutes)β
1. Start Metabaseβ
docker compose up metabase -d
Wait ~30 seconds, then open: http://localhost:3002
2. Configure Metabaseβ
- Complete initial setup (create admin account)
- Go to Settings β Admin β Embedding
- Click "Static embedding" tab (free, not the paid "Embedded Analytics")
- Enable static embedding and copy the secret key
3. Add to .envβ
METABASE_SITE_URL=http://localhost:3002
METABASE_EMBED_SECRET_KEY=<paste-secret-key-here>
4. Restart Backendβ
# If using Docker
docker compose restart backend
# If running directly
cd apps/backend && pnpm start:dev
5. Create Test Dashboardβ
- In Metabase: Browse Data β Native Query
- Run:
SELECT '{{business_id}}' AS business_id, CURRENT_DATE AS test_date - Add variable:
business_id(type: Text) - Save as question β Create dashboard
- Enable embedding on dashboard
- Lock and hide
business_idparameter - Note the Dashboard ID from URL
6. Test Backendβ
# Use the test script
./scripts/test-metabase-local.sh
# Or manually with curl
curl -X GET "http://localhost:4000/reports/dashboard/1/embed-url?businessId=550e8400-e29b-41d4-a716-446655440000" \
-H "Authorization: Bearer <YOUR_FIREBASE_TOKEN>"
7. Test Frontendβ
Add to any page:
import { MetabaseDashboardFrame } from "@/features/reports/MetabaseDashboardFrame";
<MetabaseDashboardFrame dashboardId={1} height="600px" />
β Checklistβ
- Metabase running on http://localhost:3002
- Embedding enabled in Metabase
-
METABASE_SITE_URLin.env -
METABASE_EMBED_SECRET_KEYin.env(matches Metabase) - Backend restarted with new env vars
- Test dashboard created with
business_idparameter - Backend endpoint returns embed URL
- Frontend component loads dashboard
π Common Issuesβ
| Issue | Solution |
|---|---|
| "METABASE_SITE_URL is not configured" | Add to .env and restart backend |
| "Invalid token" in dashboard | Secret keys don't match - check both places |
| Dashboard shows no data | Add WHERE business_id = {{business_id}} to query |
| Can't access Metabase | Check docker compose ps metabase |
π Full Documentationβ
See local-testing-guide.md for detailed instructions.