useLinkProfile

Links a web2 or web3 profile to the connected in-app or ecosystem account. When a profile is linked to the account, that profile can then be used to sign into the same account.

Example

Linking a social profile

import { useLinkProfile } from "thirdweb/react";
const { mutate: linkProfile } = useLinkProfile();
const onClick = () => {
linkProfile({
client,
strategy: "discord", // or "google", "x", "telegram", etc
});
};

Linking an email

import { useLinkProfile } from "thirdweb/react";
import { preAuthenticate } from "thirdweb/wallets";
const { mutate: linkProfile } = useLinkProfile();
// send a verification email first
const sendEmail = async () => {
const email = await preAuthenticate({
client,
strategy: "email",
email: "john.doe@example.com",
});
};
// then link the profile with the verification code
const onClick = (code: string) => {
linkProfile({
client,
strategy: "email",
email: "john.doe@example.com",
verificationCode: code,
});
};

The same process can be used for phone and email, simply swap out the strategy parameter.

Linking a wallet

import { useLinkProfile } from "thirdweb/react";
const { mutate: linkProfile } = useLinkProfile();
const onClick = () => {
linkProfile({
client,
strategy: "wallet",
wallet: createWallet("io.metamask"), // autocompletion for 400+ wallet ids
chain: sepolia, // any chain works, needed for SIWE signature
});
};
function useLinkProfile(): UseMutationResult<
Array<Profile>,
Error,
AuthArgsType,
unknown
>;

Returns

let returnType: UseMutationResult<
Array<Profile>,
Error,
AuthArgsType,
unknown
>;