@openhub2/metaframework-analog
v0.0.1
Published
OpenHub integration for Analog
Readme
@openhub2/metaframework-analog
OpenHub integration for Analog. Enables Analog applications to use real cloud bindings in development.
Installation
pnpm add @openhub2/metaframework-analogThen add a provider:
pnpm add @openhub2/provider-cloudflareRequires @analogjs/platform as a peer:
pnpm add @analogjs/platformUsage
Add the OpenHub plugin to your Vite configuration:
// vite.config.ts
import { defineConfig } from 'vite'
import analog from '@analogjs/platform'
import { openhubPlugin } from '@openhub2/metaframework-analog'
export default defineConfig({
plugins: [
analog(),
openhubPlugin({
provider: '@openhub2/provider-cloudflare',
remote: true, // or 'production' or 'preview'
})
]
})Configuration
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| provider | string | - | Provider package name |
| remote | boolean \| 'production' \| 'preview' | false | Enable remote mode |
Environment Variables
| Variable | Required | Description |
|----------|----------|-------------|
| OPENHUB_REMOTE_URL | In remote mode | Deployed worker URL |
| OPENHUB_REMOTE_SECRET | In remote mode | Shared auth secret |
How It Works
- Plugin registers
@openhub2/runtime-nitrowith Analog's Nitro server - Runtime registers your chosen provider
- In remote mode, bindings proxy to deployed worker
- In production, bindings are extracted from platform context
Using Bindings in Your Code
// src/server/routes/api/users.ts
import { eventHandler } from 'h3'
export default eventHandler(async (event) => {
const { database, kv, blob } = event.context.openhub.bindings
// SQL
const users = await database.prepare('SELECT * FROM users').all()
// KV
const session = await kv.get('session:123')
// Blob
const avatar = await blob.get('avatars/user-1.png')
return users
})Devtools
OpenHub adds a devtools panel accessible at /__openhub2/devtools showing:
- Current mode (local / remote / production)
- Connected provider
- Available bindings
- Proxy endpoint status
What's Included
This package includes @openhub2/runtime-nitro and @openhub2/dharma as dependencies. You only need to install a provider separately.
License
Apache-2.0
