Report incorrect code
Copy
Ask AI
function useLinkOAuth(): {
linkOAuth: (providerType: OAuth2ProviderType) => Promise<void>;
oauthState: | null
| OAuthFlowState;
};
Returns
Report incorrect code
Copy
Ask AI
{
linkOAuth: (providerType: OAuth2ProviderType) => Promise<void>;
oauthState: | null
| OAuthFlowState;
}
linkOAuth()
Report incorrect code
Copy
Ask AI
linkOAuth: (providerType: OAuth2ProviderType) => Promise<void>;
Parameters
| Parameter | Type |
|---|---|
providerType | OAuth2ProviderType |
Returns
Promise<void>
oauthState
Report incorrect code
Copy
Ask AI
oauthState:
| null
| OAuthFlowState;
Examples
Report incorrect code
Copy
Ask AI
// Google
function LinkOAuthProvider() {
const { linkOAuth } = useLinkOAuth();
const { currentUser } = useCurrentUser();
const handleLinkGoogle = async () => {
if (!currentUser) {
console.error("User must be signed in first");
return;
}
try {
await linkOAuth("google");
} catch (error) {
console.error("Failed to link Google account:", error);
}
};
return (
<button onClick={handleLinkGoogle} disabled={!currentUser}>
Link Google
</button>
);
}
Report incorrect code
Copy
Ask AI
// Apple
function LinkOAuthProvider() {
const { linkOAuth } = useLinkOAuth();
const { currentUser } = useCurrentUser();
const handleLinkApple = async () => {
if (!currentUser) {
console.error("User must be signed in first");
return;
}
try {
await linkOAuth("apple");
} catch (error) {
console.error("Failed to link Apple account:", error);
}
};
return (
<button onClick={handleLinkApple} disabled={!currentUser}>
Link Apple
</button>
);
}
Report incorrect code
Copy
Ask AI
// X
function LinkOAuthProvider() {
const { linkOAuth } = useLinkOAuth();
const { currentUser } = useCurrentUser();
const handleLinkX = async () => {
if (!currentUser) {
console.error("User must be signed in first");
return;
}
try {
await linkOAuth("x");
} catch (error) {
console.error("Failed to link X account:", error);
}
};
return (
<button onClick={handleLinkX} disabled={!currentUser}>
Link X
</button>
);
}