Skip to content

Commit 603b7d7

Browse files
committed
feat(react): add UI components to v5
1 parent 29b9817 commit 603b7d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1393
-413
lines changed

docs-site

docs/docs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,8 @@ navigation:
10831083
contents:
10841084
- section: Functions
10851085
contents:
1086+
- page: addPasskey
1087+
path: wallets/pages/reference/alchemy/wagmi-core/functions/addPasskey.mdx
10861088
- page: createConfig
10871089
path: wallets/pages/reference/alchemy/wagmi-core/functions/createConfig.mdx
10881090
- page: getAuthClient
@@ -1097,6 +1099,8 @@ navigation:
10971099
path: wallets/pages/reference/alchemy/wagmi-core/functions/listAuthMethods.mdx
10981100
- page: loginWithOauth
10991101
path: wallets/pages/reference/alchemy/wagmi-core/functions/loginWithOauth.mdx
1102+
- page: loginWithPasskey
1103+
path: wallets/pages/reference/alchemy/wagmi-core/functions/loginWithPasskey.mdx
11001104
- page: prepareCalls
11011105
path: wallets/pages/reference/alchemy/wagmi-core/functions/prepareCalls.mdx
11021106
- page: prepareSwap
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
# This file is autogenerated
3+
title: AlchemyUiProvider
4+
description: Overview of the AlchemyUiProvider method
5+
slug: wallets/reference/alchemy/react/components/AlchemyUiProvider
6+
---
7+
8+
Provider for for Alchemy UI components. `AuthCard` and `AuthModal` can only be rendered within this provider.
9+
10+
## Import
11+
12+
```ts
13+
import { AlchemyUiProvider } from "@alchemy/react";
14+
```
15+
16+
## Usage
17+
18+
```tsx
19+
import { AlchemyUiProvider, createConfig } from "@account-kit/react";
20+
import { sepolia } from "@account-kit/infra";
21+
import { QueryClient } from "@tanstack/react-query";
22+
import { wagmiConfig } from "./wagmiConfig";
23+
24+
const ui: AlchemyAccountsUIConfig = {
25+
illustrationStyle: "linear",
26+
auth: {
27+
sections: [
28+
[{ type: "email" }],
29+
[{ type: "social", authProviderId: "google", mode: "popup" }],
30+
],
31+
},
32+
};
33+
34+
const queryClient = new QueryClient();
35+
36+
function App({ children }: React.PropsWithChildren) {
37+
return (
38+
<WagmiProvider config={wagmiConfig}>
39+
<AlchemyAccountProvider queryClient={queryClient} ui={ui}>
40+
{children}
41+
</AlchemyAccountProvider>
42+
</WagmiProvider>
43+
);
44+
}
45+
```
46+
47+
## Parameters
48+
49+
### props
50+
51+
`React.PropsWithChildren<AlchemyUiProviderProps>`
52+
alchemy accounts provider props
53+
54+
### props.queryClient
55+
56+
`QueryClient`
57+
the react-query query client to use
58+
59+
### props.ui
60+
61+
`AlchemyAccountsUIConfig`
62+
ui configuration to use
63+
64+
### props.children
65+
66+
`React.ReactNode | undefined`
67+
react components that should have this accounts context
68+
69+
## Returns
70+
71+
`React.JSX.Element`
72+
The element to wrap your application in for Alchemy UI context.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
# This file is autogenerated
3+
title: AuthCard
4+
description: Overview of the AuthCard method
5+
slug: wallets/reference/alchemy/react/components/AuthCard
6+
---
7+
8+
React component containing an Auth view with configured auth methods
9+
and options based on the config passed to the AlchemyAccountProvider
10+
11+
## Import
12+
13+
```ts
14+
import { AuthCard } from "@alchemy/react";
15+
```
16+
17+
## Usage
18+
19+
```tsx
20+
import { AuthCard, useAlchemyAccountContext } from "@account-kit/react";
21+
22+
function ComponentWithAuthCard() {
23+
// assumes you've passed in a UI config to the Account Provider
24+
// you can also directly set the properties on the AuthCard component
25+
const { uiConfig } = useAlchemyAccountContext();
26+
27+
return <AuthCard {...uiConfig!.auth} />;
28+
}
29+
```
30+
31+
## Parameters
32+
33+
### props
34+
35+
`AuthCardProps`
36+
Card Props
37+
38+
## Returns
39+
40+
`JSX.Element`
41+
a react component containing the AuthCard
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
# This file is autogenerated
3+
title: AuthModal
4+
description: Overview of the AuthModal method
5+
slug: wallets/reference/alchemy/react/components/AuthModal
6+
---
7+
8+
Renders the Auth Modal component. Must be rendered within an `AlchemyUiProvider`. To customize this modal, use the `ui` prop of the `AlchemyUiProvider`.
9+
10+
## Import
11+
12+
```ts
13+
import { AuthModal } from "@alchemy/react";
14+
```
15+
16+
## Returns
17+
18+
`React.JSX.Element`
19+
The rendered Auth Modal component.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
# This file is autogenerated
3+
title: useAddPasskey
4+
description: Overview of the useAddPasskey method
5+
slug: wallets/reference/alchemy/react/hooks/useAddPasskey
6+
---
7+
8+
React hook for adding a passkey to an already authenticated account.
9+
10+
This hook uses the `addPasskey` mutation to add a passkey to the authenticated account.
11+
12+
## Import
13+
14+
```ts
15+
import { useAddPasskey } from "@alchemy/react";
16+
```
17+
18+
## Usage
19+
20+
```tsx twoslash
21+
import { useAddPasskey } from "@alchemy/react";
22+
23+
function AddPasskeyForm() {
24+
const { addPasskey, isPending } = useAddPasskey();
25+
}
26+
```
27+
28+
## Parameters
29+
30+
### parameters
31+
32+
`UseAddPasskeyParameters`
33+
34+
- Configuration options for the hook
35+
36+
## Returns
37+
38+
`UseAddPasskeyReturnType`
39+
TanStack Query mutation object
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
# This file is autogenerated
3+
title: useAuthModal
4+
description: Overview of the useAuthModal method
5+
slug: wallets/reference/alchemy/react/hooks/useAuthModal
6+
---
7+
8+
A [hook](https://github.com/alchemyplatform/aa-sdk/blob/main/account-kit/react/src/hooks/useAuthModal.ts) that returns the open and close functions for the Auth Modal if uiConfig
9+
is enabled on the Account Provider
10+
11+
## Import
12+
13+
```ts
14+
import { useAuthModal } from "@alchemy/react";
15+
```
16+
17+
## Usage
18+
19+
```tsx twoslash
20+
import React from "react";
21+
import { useAuthModal } from "@account-kit/react";
22+
23+
const ComponentWithAuthModal = () => {
24+
const { openAuthModal } = useAuthModal();
25+
26+
return (
27+
<div>
28+
<button onClick={openAuthModal}>Login</button>
29+
</div>
30+
);
31+
};
32+
```
33+
34+
## Returns
35+
36+
`UseAuthModalResult`
37+
an object containing methods for opening or closing the auth modal. [ref](https://github.com/alchemyplatform/aa-sdk/blob/main/account-kit/react/src/hooks/useAuthModal.ts#L4)
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
# This file is autogenerated
3+
title: useLoginWithPasskey
4+
description: Overview of the useLoginWithPasskey method
5+
slug: wallets/reference/alchemy/react/hooks/useLoginWithPasskey
6+
---
7+
8+
React hook for Passkey authentication - initiates authentication flow with the specified options.
9+
10+
This hook wraps the `loginWithPasskey` action with React Query mutation functionality,
11+
providing loading states, error handling, and mutation management for the OAuth authentication flow.
12+
13+
## Import
14+
15+
```ts
16+
import { useLoginWithPasskey } from "@alchemy/react";
17+
```
18+
19+
## Usage
20+
21+
```tsx twoslash
22+
import { useLoginWithPasskey } from "@alchemy/react";
23+
24+
function LoginForm() {
25+
const { loginWithPasskey, isPending, error } = useLoginWithPasskey();
26+
27+
const handleGoogleLogin = () => {
28+
loginWithPasskey({
29+
provider: "google",
30+
mode: "popup", // or 'redirect'
31+
});
32+
};
33+
34+
return (
35+
<button onClick={handleGoogleLogin} disabled={isPending}>
36+
{isPending ? "Logging in..." : "Login with Google"}
37+
</button>
38+
);
39+
}
40+
```
41+
42+
## Parameters
43+
44+
### parameters
45+
46+
`UseLoginWithPasskeyParameters`
47+
48+
- Configuration options for the hook
49+
50+
### parameters.config
51+
52+
`Config`
53+
54+
- Optional wagmi config override
55+
56+
### parameters.mutation
57+
58+
`UseMutationParameters`
59+
60+
- Optional React Query mutation configuration
61+
62+
## Returns
63+
64+
`UseLoginWithPasskeyReturnType`
65+
TanStack Query mutation object with the following properties:
66+
67+
- `loginWithPasskey`: `(variables: LoginWithPasskeyParameters, options?) => void` - Mutation function to initiate OAuth login
68+
- `loginWithPasskeyAsync`: `(variables: LoginWithPasskeyParameters, options?) => Promise<LoginWithPasskeyReturnType>` - Async mutation function that returns a promise
69+
- `data`: `LoginWithPasskeyReturnType | undefined` - The last successfully resolved data (void)
70+
- `error`: `Error | null` - The error object for the mutation, if an error was encountered
71+
- `isError`: `boolean` - True if the mutation is in an error state
72+
- `isIdle`: `boolean` - True if the mutation is in its initial idle state
73+
- `isPending`: `boolean` - True if the mutation is currently executing
74+
- `isSuccess`: `boolean` - True if the last mutation attempt was successful
75+
- `failureCount`: `number` - The failure count for the mutation
76+
- `failureReason`: `Error | null` - The failure reason for the mutation retry
77+
- `isPaused`: `boolean` - True if the mutation has been paused
78+
- `reset`: `() => void` - Function to reset the mutation to its initial state
79+
- `status`: `'idle' | 'pending' | 'error' | 'success'` - Current status of the mutation
80+
- `submittedAt`: `number` - Timestamp for when the mutation was submitted
81+
- `variables`: `LoginWithPasskeyParameters | undefined` - The variables object passed to the mutation
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
# This file is autogenerated
3+
title: addPasskey
4+
description: Overview of the addPasskey method
5+
slug: wallets/reference/alchemy/wagmi-core/functions/addPasskey
6+
---
7+
8+
Adds a passkey to the authenticated user's account.
9+
10+
## Import
11+
12+
```ts
13+
import { addPasskey } from "@alchemy/wagmi-core";
14+
```
15+
16+
## Parameters
17+
18+
### config
19+
20+
`Config`
21+
22+
- The shared Wagmi/Alchemy config
23+
24+
### parameters
25+
26+
`AddPasskeyParameters`
27+
28+
- The parameters for the passkey creation
29+
30+
## Returns
31+
32+
`Promise<AddPasskeyReturnType>`
33+
Promise that resolves when the passkey is added
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
# This file is autogenerated
3+
title: loginWithPasskey
4+
description: Overview of the loginWithPasskey method
5+
slug: wallets/reference/alchemy/wagmi-core/functions/loginWithPasskey
6+
---
7+
8+
Initiates Passkey authentication flow with the specified parameters.
9+
10+
## Import
11+
12+
```ts
13+
import { loginWithPasskey } from "@alchemy/wagmi-core";
14+
```
15+
16+
## Parameters
17+
18+
### config
19+
20+
`Config`
21+
22+
- The shared Wagmi/Alchemy config
23+
24+
### parameters
25+
26+
`LoginWithPasskeyParameters`
27+
28+
- Passkey authentication parameters
29+
30+
## Returns
31+
32+
`Promise<LoginWithPasskeyReturnType>`
33+
Promise that resolves when authentication completes and connection is established

0 commit comments

Comments
 (0)