Skip to content

Getting Started

Installation

Install X511 and its peer dependencies:

bash
npm install hono x511-tba

Configuration

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

OptionTypeRequiredDescription
domainstringYesPublic base URL of your server (no trailing slash)
basePathstringNoRoute prefix for internal X511 endpoints. Defaults to '/'
providers('self' | 'zkpassport')[]YesWhich verification providers to offer
disclousures.minAgenumberYesMinimum 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.