diff --git a/account-kit/react/src/components/auth/card/add-passkey.tsx b/account-kit/react/src/components/auth/card/add-passkey.tsx index 7f6c171c1c..f458a860aa 100644 --- a/account-kit/react/src/components/auth/card/add-passkey.tsx +++ b/account-kit/react/src/components/auth/card/add-passkey.tsx @@ -1,5 +1,4 @@ import { useAddPasskey } from "../../../hooks/useAddPasskey.js"; -import { useUiConfig } from "../../../hooks/useUiConfig.js"; import { AddPasskeyIllustration } from "../../../icons/illustrations/add-passkey.js"; import { PasskeyShieldIllustration, @@ -25,7 +24,6 @@ const BENEFITS = [ // eslint-disable-next-line jsdoc/require-jsdoc export const AddPasskey = () => { - const { illustrationStyle } = useUiConfig(); const { setAuthStep } = useAuthContext(); const { addPasskey, isAddingPasskey } = useAddPasskey({ onSuccess: () => { @@ -36,11 +34,7 @@ export const AddPasskey = () => { return (
{title}
diff --git a/account-kit/react/src/components/auth/card/index.tsx b/account-kit/react/src/components/auth/card/index.tsx index c9a1896c70..79da19e65a 100644 --- a/account-kit/react/src/components/auth/card/index.tsx +++ b/account-kit/react/src/components/auth/card/index.tsx @@ -11,6 +11,7 @@ import { Navigation } from "../../navigation.js"; import { Notification } from "../../notification.js"; import { useAuthContext } from "../context.js"; import { Step } from "./steps.js"; +import { useSigner } from "../../../hooks/useSigner.js"; export type AuthCardProps = { className?: string; @@ -41,35 +42,44 @@ export const AuthCardContent = ({ const { status, isAuthenticating } = useSignerStatus(); const { authStep, setAuthStep } = useAuthContext(); + const signer = useSigner(); const error = useAuthError(); const contentRef = useRef
diff --git a/account-kit/react/src/createConfig.ts b/account-kit/react/src/createConfig.ts
index 0c8e4003d2..da9f22380d 100644
--- a/account-kit/react/src/createConfig.ts
+++ b/account-kit/react/src/createConfig.ts
@@ -14,6 +14,26 @@ export type AlchemyAccountsConfigWithUI = AlchemyAccountsConfig & {
* an additional argument, the configuration object for the Auth Components UI
* (the modal and AuthCard).
*
+ * @example
+ * ```ts
+ * import { sepolia } from "@account-kit/infra"
+ * import { createConfig } from "@account-kit/react"
+ *
+ * const uiConfig = {
+ * illustrationStyle: "linear",
+ * auth: {
+ * sections: [[{ type: "email" }], [{ type: "passkey" }]],
+ * addPasskeyOnSignup: true,
+ * },
+ * }
+ *
+ * const config = createConfig({
+ * rpcUrl: "/api/rpc",
+ * chain: sepolia,
+ * ssr: true,
+ * }, uiConfig)
+ * ```
+ *
* @param {CreateConfigProps} props for creating an alchemy account config
* @param {AlchemyAccountsUIConfig} ui the configuration to use for the Auth Components UI
* @returns an alchemy account config object containing the core and client store, as well as the UI config
diff --git a/account-kit/react/src/hooks/useUiConfig.ts b/account-kit/react/src/hooks/useUiConfig.ts
index a34a320dc9..30e68e3dde 100644
--- a/account-kit/react/src/hooks/useUiConfig.ts
+++ b/account-kit/react/src/hooks/useUiConfig.ts
@@ -2,6 +2,7 @@
import { useAlchemyAccountContext } from "../context.js";
import { MissingUiConfigError } from "../errors.js";
+import type { AlchemyAccountsUIConfig } from "../types.js";
export const useUiConfig = () => {
const { ui } = useAlchemyAccountContext();
@@ -9,7 +10,20 @@ export const useUiConfig = () => {
throw new MissingUiConfigError("useUiConfig");
}
+ // We set some defaults here
return {
...ui.config,
- };
+ illustrationStyle: ui.config.illustrationStyle ?? "flat",
+ auth: {
+ ...ui.config.auth,
+ addPasskeyOnSignup: ui.config.auth?.addPasskeyOnSignup ?? false,
+ header: ui.config.auth?.header ?? null,
+ hideError: ui.config.auth?.hideError ?? false,
+ sections: ui.config.auth?.sections ?? [
+ [{ type: "email" }],
+ [{ type: "passkey" }],
+ ],
+ showSignInText: ui.config.auth?.showSignInText ?? true,
+ },
+ } satisfies AlchemyAccountsUIConfig;
};
diff --git a/account-kit/react/src/icons/illustrations/add-passkey.tsx b/account-kit/react/src/icons/illustrations/add-passkey.tsx
index 92e4287d8d..1c3a3e0ca5 100644
--- a/account-kit/react/src/icons/illustrations/add-passkey.tsx
+++ b/account-kit/react/src/icons/illustrations/add-passkey.tsx
@@ -1,15 +1,16 @@
import { type SVGProps } from "react";
-import type { IllustrationProps } from "./types.js";
+import { useUiConfig } from "../../hooks/useUiConfig.js";
// eslint-disable-next-line jsdoc/require-jsdoc
export const AddPasskeyIllustration = ({
className,
- illustrationStyle: style,
...props
-}: IllustrationProps) => {
+}: JSX.IntrinsicAttributes & SVGProps