Quick Start
This guide walks you through adding UseBetter Console to an existing Hono application. Choose the tab that matches your environment — development (instant setup, no database) or production (magic link auth with Drizzle).
Auto-approve issues a stateless JWT immediately — no database tables, no email flow. Use this for local development.
-
Generate a connection token
Terminal window npx @usebetterdev/console-cli init --email admin@localhost -nThis prints two environment variables. Copy
BETTER_CONSOLE_TOKEN_HASH— you’ll need it in the next step. -
Add to your
.env.env BETTER_CONSOLE_TOKEN_HASH=sha256:e5f6a7b8... -
Add the middleware
src/index.ts import { Hono } from "hono";import { betterConsole } from "@usebetterdev/console";import { createConsoleMiddleware } from "@usebetterdev/console/hono";const app = new Hono();const consoleInstance = betterConsole({connectionTokenHash: process.env.BETTER_CONSOLE_TOKEN_HASH!,sessions: { autoApprove: process.env.NODE_ENV === "development" },});app.use("*", createConsoleMiddleware(consoleInstance));// Your existing routes below...app.get("/", (c) => c.text("Hello!"));export default app; -
Verify the health endpoint
Terminal window curl http://localhost:3000/.well-known/better/console/healthYou should see
{"status":"ok"}. -
Open the Console UI
Visit
console.usebetter.dev, enter your server URL (e.g.,http://localhost:3000), and authenticate. Auto-approve grants a session token instantly.
Magic link uses a 3-step handshake with email verification. Requires Drizzle and a PostgreSQL database.
-
Generate a connection token
Terminal window This prints two environment variables. Copy both.
-
Add to your
.env.env BETTER_CONSOLE_TOKEN_HASH=sha256:e5f6a7b8... -
Create the database tables
Generate the migration SQL and apply it:
Terminal window # Option A: Generate a file, then apply with your migration toolnpx @usebetterdev/console-cli migrate -o drizzle/console_tables.sql# Option B: Pipe directly to psqlnpx @usebetterdev/console-cli migrate --dry-run | psql $DATABASE_URLThis creates two tables:
better_console_sessionsandbetter_console_magic_links. -
Add the middleware with Drizzle adapter
src/index.ts import { Hono } from "hono";import { drizzle } from "drizzle-orm/node-postgres";import { Pool } from "pg";import { betterConsole } from "@usebetterdev/console";import { drizzleConsoleAdapter } from "@usebetterdev/console/drizzle";import { createConsoleMiddleware } from "@usebetterdev/console/hono";const pool = new Pool({ connectionString: process.env.DATABASE_URL });const db = drizzle(pool);const app = new Hono();const consoleInstance = betterConsole({adapter: drizzleConsoleAdapter(db),connectionTokenHash: process.env.BETTER_CONSOLE_TOKEN_HASH!,sessions: {magicLink: {allowedEmails: process.env.BETTER_CONSOLE_ALLOWED_EMAILS!,},},});app.use("*", createConsoleMiddleware(consoleInstance));// Your existing routes below...app.get("/", (c) => c.text("Hello!"));export default app; -
Verify the setup
Terminal window npx @usebetterdev/console-cli check --database-url $DATABASE_URLAll checks should pass.
-
Open the Console UI
Visit
console.usebetter.dev, enter your server URL (e.g.,https://myapp.com), and authenticate via magic link. A 6-character code is sent to your email — enter it in the UI to complete authentication.
What just happened?
Section titled “What just happened?”- The CLI generated a connection token pair. The hash is stored in your environment and used server-side to sign/verify session JWTs. The raw token is only shown once during init.
- The middleware intercepts all
/.well-known/better/*requests and delegates them tohandleConsoleRequest(). - The Console UI at
console.usebetter.devcalls your server’s endpoints to authenticate and discover registered products. No data leaves your infrastructure — the UI is a static frontend that talks directly to YOUR server.
Next steps
Section titled “Next steps”- Configuration — all config options, permissions, CORS, environment variables
- Authentication — auto-approve, magic link, custom auth hook
- Product Registration — expose data to the Console UI
- CLI — all CLI commands