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 8 commits into
base: main
Choose a base branch
from
26 changes: 24 additions & 2 deletions site/pages/react/react-hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 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,16 @@ 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]",
emailMode: "magicLink",
redirectParams,
});

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