Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: redirect params in auth hooks #1222

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions site/pages/react/react-hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Tailwind CSS is a required dependency for using Alchemy Account Kit UI component

### Email authentication

```tsx twoslash
````tsx twoslash
import React from "react";
import {
type UseAuthenticateResult,
Expand All @@ -33,13 +33,35 @@ export default function MyLoginPage() {
value={email}
onChange={(e) => setEmail(e.target.value)}
/>
<button onClick={() => authenticate({ type: "email", email })}>
<button
onClick={() => authenticate({ type: "email", email, emailMode: "otp" })}
>
Login
</button>
</div>
);
}
```

// Then send the OTP

export default function MyOTPInputPage() {
const { authenticate, isPending } = useAuthenticate();
const [otpCode, setOTPCode] = React.useState("");

return (
<div>
<input
value={otpCode}
onChange={(e) => setOTPCode(e.target.value)}
/>
<button
onClick={() => authenticate({ type: "otp", otpCode });}
>
Submit
</button>
</div>
);
}

### Social Login

Expand Down Expand Up @@ -88,7 +110,7 @@ export default function MyLoginPage() {
</div>
);
}
```
````

To use your own auth provider, follow the instructions on how to do so with [Auth0](https://accountkit.alchemy.com/signer/authentication/auth0)

Expand Down
5 changes: 5 additions & 0 deletions site/pages/signer/authentication/email-magic-link.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ await signer.authenticate({
email: "[email protected]",
});

// Instead of the above code, you can add some params to include in the email
const redirectParams = new URLSearchParams();
redirectParams.set("myParam", "someValue");
signer.authenticate({ type: "email", email: "[email protected]", redirectParams });
RobChangCA marked this conversation as resolved.
Show resolved Hide resolved

// later once the user has clicked the link
const url = new URL(window.location.href);
const bundle = url.searchParams.get("bundle");
Expand Down
Loading