Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.edgespark.dev/llms.txt

Use this file to discover all available pages before exploring further.

auth gives you access to the current authenticated user. Import it from edgespark/http in your server code.

auth.user

The authenticated user object is available in protected routes:
server/src/index.ts
import { auth } from "edgespark/http";
import { Hono } from "hono";

const app = new Hono().get("/api/me", (c) => {
  const { id, email, name } = auth.user;
  return c.json({ id, email, name });
});

export default app;

auth.isAuthenticated()

Use auth.isAuthenticated() when you want a type-safe guard in routes that allow anonymous access:
server/src/index.ts
import { auth } from "edgespark/http";
import { Hono } from "hono";

const app = new Hono().get("/api/public/viewer", (c) => {
  if (!auth.isAuthenticated()) {
    return c.json({ user: null });
  }

  return c.json({
    user: {
      id: auth.user.id,
      email: auth.user.email,
    },
  });
});

export default app;

When user is available

Route patternauth.user
/api/*Always a valid user
/api/public/*User if logged in, otherwise null
/api/webhooks/*Always null
See path-based auth for the full rules.

See also

Authenticate users

Guide to protected routes, optional auth, and webhook verification.

Path-based auth

How URL path conventions control authentication behavior.
Last modified on April 7, 2026