@authhero/admin

中文文档
0.26.5发布于 2026/11/05AGPL-3.0-onlyCommonJS构建来源已验证近 30 天下载 2144

The AuthHero admin UI — a Vite + React 19 SPA for managing tenants, users, applications, connections, roles, branding and more across one or many AuthHero deployments.

原始使用文档
文档目录9 节
  1. Quick start
  2. Configuration
  3. Settings
  4. Build-time env example
  5. Runtime config example
  6. Whitelabeling
  7. Deploying to Cloudflare Pages
  8. Multiple Cloudflare accounts
  9. Architecture notes

@authhero/admin

The AuthHero admin UI — a Vite + React 19 SPA for managing tenants, users, applications, connections, roles, branding and more across one or many AuthHero deployments.

Built on ra-core (the headless half of react-admin) with shadcn/ui and Tailwind v4.

Quick start

# from the repo root
pnpm install
pnpm admin dev        # starts on http://localhost:5173

# or from this directory
pnpm dev
pnpm build            # production bundle in ./dist
pnpm type-check
pnpm test

Configuration

The admin reads its configuration from two sources, in priority order:

  1. Runtime config — window.__AUTHHERO_ADMIN_CONFIG__ (injected by the host page before the bundle loads). Useful when the same static build is served to multiple environments.
  2. Build-time env vars — VITE_* variables baked in at pnpm build time.

Both paths share the same keys, defined in src/utils/runtimeConfig.ts.

Settings

SettingEnv varRuntime keyDefaultDescription
Auth0 domainVITE_AUTH0_DOMAINdomain—Tenant domain used by @auth0/auth0-spa-js to log the admin user in. When unset, the user is prompted to pick a domain on first load.
Auth0 client IDVITE_AUTH0_CLIENT_IDclientId—SPA application client ID for the admin itself.
Management API URLVITE_AUTH0_API_URLapiUrl—Base URL of the AuthHero management API (e.g. https://auth.example.com).
Auth0 audienceVITE_AUTH0_AUDIENCEaudience—Audience requested for the management API access token.
Base pathVITE_BASE_PATHbasePath""Sub-path the admin is served from (e.g. /admin). Routes and the OAuth callback honor this.
App nameVITE_APP_NAMEappName"AuthHero Admin"Browser tab title and the wordmark shown in the top bar (when no logo is set).
Logo URLVITE_APP_LOGO_URLlogoUrl—Image rendered in the top bar in place of the wordmark. Anything browsers can display (PNG, SVG, WebP). Recommended height: 28px.
Favicon URLVITE_APP_FAVICON_URLfaviconUrl./favicon.svgOverrides the built-in favicon.

Build-time env example

Create apps/admin/.env.local:

VITE_AUTH0_DOMAIN=auth.example.com
VITE_AUTH0_CLIENT_ID=your-spa-client-id
VITE_AUTH0_API_URL=https://auth.example.com
VITE_AUTH0_AUDIENCE=https://auth.example.com/api/v2/
VITE_BASE_PATH=/admin

# Whitelabel
VITE_APP_NAME="Acme Identity Console"
VITE_APP_LOGO_URL=https://cdn.example.com/acme-logo.svg
VITE_APP_FAVICON_URL=https://cdn.example.com/acme-favicon.svg

Runtime config example

Inject before the bundle to swap settings without rebuilding:

<script>
  window.__AUTHHERO_ADMIN_CONFIG__ = {
    domain: "auth.example.com",
    clientId: "your-spa-client-id",
    apiUrl: "https://auth.example.com",
    audience: "https://auth.example.com/api/v2/",
    basePath: "/admin",
    appName: "Acme Identity Console",
    logoUrl: "https://cdn.example.com/acme-logo.svg",
    faviconUrl: "https://cdn.example.com/acme-favicon.svg",
  };
</script>
<script type="module" src="/admin/assets/index-<hash>.js"></script>

The bundle entry filename is fingerprinted by Vite at build time (e.g. index-Ab12Cd.js), so substitute the real filename from your build output — or use window.__AUTHHERO_ADMIN_CONFIG__.basePath to construct it from the configured base path.

If neither source provides a domain, the admin shows a domain picker on first load and stores the choice in a cookie via src/utils/domainUtils.ts.

Whitelabeling

The three branding settings (appName, logoUrl, faviconUrl) are read in three places:

To replace the default mark, set VITE_APP_FAVICON_URL to your own asset; the bundled default lives at public/favicon.svg.

Deploying to Cloudflare Pages

The admin is a static SPA, so any static host works. Cloudflare Pages is the recommended target.

In the Cloudflare dashboard, Workers & Pages → Create → Pages → Connect to Git, then:

SettingValue
Build commandpnpm install --no-frozen-lockfile && pnpm --filter "@authhero/admin..." build
Build output directorydist
Root directory (advanced)apps/admin
Environment variablesNODE_VERSION=20, ENABLE_EXPERIMENTAL_COREPACK=1, plus the VITE_* settings from the table above

The trailing ... on the pnpm filter is required — it builds admin's workspace dependencies (notably @authhero/adapter-interfaces) before admin itself. Without it, vite fails to resolve @authhero/adapter-interfaces because the symlinked package has no built dist/.

For SPA client-side routing, add public/_redirects:

/*    /index.html   200

Multiple Cloudflare accounts

Cloudflare's Git integration binds a repo to a single Cloudflare account. To deploy the same codebase to several accounts, you have two options:

  1. GitHub Actions + Wrangler — disconnect the Pages Git integration and deploy from CI with cloudflare/wrangler-action, supplying each account's CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID as separate GitHub secrets. Build once, deploy N times via a matrix job. Per-account VITE_* values can be set as workflow env at build time, or use the runtime window.__AUTHHERO_ADMIN_CONFIG__ to ship a single artifact.
  2. Fork per environment — fork the repo into each Cloudflare account's organisation and connect each fork's Pages project to its own fork. Lower setup cost, at the price of having to merge changes upstream and keep forks in sync.

Architecture notes

  • Dual router: the outer router in src/index.tsx handles domain selection (/), tenant management (/tenants/*), per-tenant admin (/:tenantId/*) and the OAuth callback (/auth-callback). The inner router in src/App.tsx is the react-admin router mounted with basename="/:tenantId".
  • Auth: @auth0/auth0-spa-js against the configured domain/clientId/audience. The provider lives in src/authProvider.ts.
  • Data: a custom data provider in src/auth0DataProvider.ts talks to the AuthHero management API.

See the full docs at authhero.net/apps/admin/.

版本与发布记录

@authhero/admin 共发布 93 个版本,首次发布于 2026/05/18;过去 12 个月发布了 93 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.26.5latest2026/11/052 天前
0.26.42026/11/043 天前
0.26.32026/11/043 天前
0.26.22026/11/034 天前
0.26.12026/11/034 天前
0.26.02026/10/308 天前

关于 @authhero/admin 的常见问题

@authhero/admin 是什么?

The AuthHero admin UI — a Vite + React 19 SPA for managing tenants, users, applications, connections, roles, branding and more across one or many AuthHero deployments.

如何安装 @authhero/admin?

在项目目录运行 npm install @authhero/admin,或使用 pnpm add / yarn add / bun add。

@authhero/admin 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/authhero__admin 是否存在。

@authhero/admin 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@authhero/admin 可以商用吗?

@authhero/admin 使用 AGPL-3.0-only 许可。最严格的 Copyleft:除分发外,通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括,不构成法律意见,请以许可原文为准。

@authhero/admin 的下载量有多少?

根据 npm 官方下载统计,@authhero/admin 在 2026/10/07 – 2026/11/05 这 30 天内被下载 2,144 次,日均约 71 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@authhero/admin 还在维护吗?

最新版本 0.26.5 发布于 2026/11/05(2 天前);至今共发布 93 个版本,其中过去 12 个月发布了 93 个;首次发布于 2026/05/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。