Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
function LinkAuth(props: LinkAuthProps): Element;
props
LinkAuthProps
Element
// Render the LinkAuth component with a custom success handler function App() { return ( <CDPReactProvider config={config}> <LinkAuth onLinkSuccess={method => console.log(`Linked ${method}`)} /> </CDPReactProvider> ); }
// Recreate the default UI function App() { return ( <CDPReactProvider config={config}> <LinkAuth> <div className="header"> <LinkAuthTitle /> <LinkAuthFlowBackButton /> </div> <div className="error"> <LinkAuthError /> </div> <LinkAuthFlow /> </LinkAuth> </CDPReactProvider> ); }
// Add a message based on the LinkAuth state function App() { return ( <CDPReactProvider config={config}> <LinkAuth> {state => ( <> <div className="header"> <LinkAuthTitle /> <LinkAuthFlowBackButton /> </div> {state.methodToLink && ( <p className="message"> Linking {state.methodToLink}... </p> )} <div className="error"> <LinkAuthError /> </div> <LinkAuthFlow /> </> )} </LinkAuth> </CDPReactProvider> ); }
// Customize LinkAuthItems to show a modal for non-OAuth methods instead of transitioning in place. function CustomLinkAuthItems() { const { link, back } = useLinkAuthFlow(); const { authMethods } = useAppConfig(); const [openModal, setOpenModal] = useState<AuthMethod | null>(null); const modalMethods = useMemo( () => authMethods.filter(method => !method.startsWith("oauth:")), [authMethods], ); const handleClose = useCallback(() => { setOpenModal(null); back(); }, [back, setOpenModal]); const handleLink = useCallback( (method: AuthMethod) => { link(method); if (!method.startsWith("oauth:")) { setOpenModal(method); } }, [link, setOpenModal], ); return ( <> <LinkAuthItems onLink={handleLink} /> {modalMethods.map(method => { return ( <SignInModal key={method} open={openModal === method} authMethods={[method]} setIsOpen={isOpen => (isOpen ? setOpenModal(method) : handleClose())} onSuccess={() => setOpenModal(null)} > <SignInModalTrigger>null</SignInModalTrigger> </SignInModal> ); })} </> ); }; function App() { return ( <CDPReactProvider config={config}> <LinkAuth> <h2>Link a profile</h2> <CustomLinkAuthItems /> </LinkAuth> </CDPReactProvider> ); }
Was this page helpful?