@atlasauth/react

中文文档
0.38.0发布于 2026/11/17TypeScriptCommonJS近 30 天下载 5963

React components and hooks for Atlas.

原始使用文档

@atlasauth/react

React components and hooks for Atlas.

Sign in with Atlas (any website)

Let people sign in to any site with their Atlas account. No <AtlasProvider> needed.

import { SignInWithAtlasButton, completeSignInWithAtlas } from '@atlasauth/react';

<SignInWithAtlasButton clientId="YOUR_CLIENT_ID" redirectUri="https://example.com/callback" />;

// On the redirect page:
const { idToken, claims } = await completeSignInWithAtlas();

Register an app under Account → Sign in with Atlas in the dashboard. Always verify idToken on your server (signature via JWKS, iss, aud, exp) before trusting it. Use buildAtlasAuthorizeUrl() for a custom button.

Server app (one with a client secret)? The code must be exchanged by your server, so let the button hand off to your backend login route instead of running PKCE in the browser:

<SignInWithAtlasButton loginUri="/auth/atlas/login" />

loginUri must be a same-origin path or an https:// URL.

<SignIn> / <SignUp> options

<SignIn
  layout={{ alternativeMethods: 'inside' }}
  initialValues={{ email: '[email protected]' }}
/>
  • layout.alternativeMethods places the passkey button and the social / "Continue with Atlas" buttons of <SignIn>: 'inside' the card under the form, 'below' the card (the default, unchanged from earlier versions) or 'above' it. <SignUp> already keeps its alternatives inside the card. The passkey button is a secondary button (formButtonSecondary in appearance.elements, .atlas-button-secondary).
  • initialValues.email prefills the email field (the identifier on <SignIn>). Without it, a login_hint or email query parameter on the page URL prefills it; initialValues wins.

版本与发布记录

@atlasauth/react 共发布 89 个版本,首次发布于 2026/09/14;过去 12 个月发布了 89 个版本。

版本发布日期距今
0.38.0latest2026/11/17今天
0.37.0next2026/11/152 天前
0.36.02026/11/152 天前
0.35.12026/11/152 天前
0.35.02026/11/143 天前
0.34.22026/11/134 天前

关于 @atlasauth/react 的常见问题

@atlasauth/react 是什么?

React components and hooks for Atlas.

如何安装 @atlasauth/react?

在项目目录运行 npm install @atlasauth/react,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=18)、@atlasauth/js(>=0.39.0 <1.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@atlasauth/react 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@atlasauth/react 支持 ESM 还是 CommonJS?

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

@atlasauth/react 可以商用吗?

@atlasauth/react 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@atlasauth/react 的下载量有多少?

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

@atlasauth/react 还在维护吗?

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