Skip to main content
@edgespark/web is the browser SDK used by the current EdgeSpark scaffold. It is:
  • browser-only
  • same-origin only
  • cookie-session only
  • zero-config
It is meant for browser apps only. Do not use it in server code.

Create the client

web/src/lib/edgespark.ts
createEdgeSpark() takes no options.

client.auth

client.auth keeps the familiar Better Auth method shape and adds EdgeSpark session helpers.
web/src/lib/session.ts
You can also call the standard auth methods directly:
web/src/lib/auth.ts
Current platform note:
  • changeEmail()
  • deleteUser()
still exist on the familiar auth surface, but they are not currently enabled by the platform and fail fast with UNSUPPORTED_AUTH_METHOD.

client.api.fetch

Use client.api.fetch(...) for app requests from the browser:
web/src/lib/load-profile.ts
The wrapper always sends cookie credentials and rejects cross-origin URLs.

client.authUI

Use the managed auth UI when you want EdgeSpark to render login, sign-up, verification, OAuth, and password reset flows.

Redirect mode

Controlled mode

Destroy the mounted UI when the container is going away:
Password reset is the one special completion case:
  • in controlled mode, onSuccess({ action: "password-reset" }) fires and your app decides what to do next
  • in redirect mode, the UI returns to sign-in with a success notice instead of redirecting to an authenticated page

Error classes

@edgespark/web exports normalized error classes you can catch explicitly:
  • EdgeSparkAuthError for auth failures such as rejected sign-in or missing session
  • EdgeSparkConfigError for bad inputs such as invalid redirect targets or cross-origin fetches
  • EdgeSparkRuntimeError when called outside a browser runtime

Redirect targets

redirectTo can be a relative path or absolute URL:
It must resolve to a valid http: or https: URL.

Locale presets

The managed UI auto-detects labels from the browser by default. Import a preset only when you want to force a specific language:
The package also exports detectLocale() if you want the same browser-language detection logic outside the managed UI.

See also

Build auth UI

Mount the managed UI in a real app and wire redirect or controlled flows.

Authenticate users

Server-side auth rules for /api/*, /api/public/*, and /api/webhooks/*.
Last modified on April 7, 2026