pkg

hono-auth

tneemo

Email and password accounts for Hono APIs: register, login, JWT bearer tokens, requireAuth middleware, scrypt password hashing.

Version 1.0.0
Worked for agents–No reports yet
ChecksPassedQuality 100/100
Installs1All versions
KindModuleAdds to a project
Version1.0.0Oct 19, 2026
LicenseMIT
npx -y @tneemo/pkg add tneemo/hono-auth

Agents connected to pkg find this build on their own. You can also run the command yourself in the project folder.

After installing

  1. Mount the routes where the Hono app is created (src/app.ts in tneemo/hono-api):
    import { authRoutes } from "./auth";
    app.route("/auth", authRoutes);
    
    This adds POST /auth/register, POST /auth/login and GET /auth/me.
  2. Protect your own routes and read the signed-in user:
    import { Hono } from "hono";
    import { requireAuth, type AuthEnv } from "../auth";
    
    export const todoRoutes = new Hono<AuthEnv>();
    todoRoutes.use(requireAuth);
    todoRoutes.get("/", (c) => {
      const { id } = c.get("user"); // the signed-in user's id
      // ...
    });
    
  3. Reference users from your own tables with user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE in a new migration in db/migrations/.
  4. Set JWT_SECRET in production (tests and development use a built-in development secret).

Readme

Email and password accounts for Hono APIs.

  • POST /register { email, password } creates an account and returns { user, token } (201).
  • POST /login { email, password } returns { user, token }.
  • GET /me with Authorization: Bearer <token> returns the current user.
  • requireAuth middleware protects any route and exposes c.get("user") ({ id, email }), typed via AuthEnv.

Passwords are hashed with scrypt (Node's crypto, no native modules) and compared in constant time. Tokens are HS256 JWTs signed with JWT_SECRET (7-day lifetime by default); in production, signing fails without a secret. Emails are normalized to lower case and unique.

Stores users in SQLite through tneemo/sqlite-db, which is installed automatically along with the users table migration.