Getting Started
Installation
Install X511 and its peer dependencies:
bash
npm install hono x511-tbaConfiguration
Create an x511 instance with your configuration:
ts
import { x511 } from 'x511-tba'
const gate = x511({
domain: 'https://your-app.example.com',
basePath: '/x511',
providers: ['self', 'zkpassport'],
disclousures: {
minAge: 18,
},
})Configuration options
| Option | Type | Required | Description |
|---|---|---|---|
domain | string | Yes | Public base URL of your server (no trailing slash) |
basePath | string | No | Route prefix for internal X511 endpoints. Defaults to '/' |
providers | ('self' | 'zkpassport')[] | Yes | Which verification providers to offer |
disclousures.minAge | number | Yes | Minimum age the user must prove (e.g. 18) |
Minimal Example
For a quick local test with only the Self provider:
ts
import { Hono } from 'hono'
import { serve } from '@hono/node-server'
import { x511, toHono } from 'x511-tba'
const app = new Hono()
const gate = x511({
domain: 'http://localhost:3000',
basePath: '/x511',
providers: ['self'],
disclousures: { minAge: 18 },
})
app.all('/x511/*', (c) => gate.verify(c.req.raw))
app.get('/adults-only', toHono(gate.verified), (c) =>
c.text('Welcome, verified adult!'),
)
serve({ fetch: app.fetch, port: 3000 })Visit http://localhost:3000/adults-only in a browser - you will be redirected to the 511 verification page.