Guide to integrating Mubarokah ID with a React application using the official SDK.
React Integration Guide
This guide explains how to integrate Mubarokah ID Single Sign-On into your React application using our official TypeScript SDK. The SDK provides a native React Context and Hooks designed for Single Page Applications (SPA), handles PKCE (Proof Key for Code Exchange) automatically, and manages session state.
Installation
Install the official SDK via npm:
npm install mubarokah-id-sdk
Setup
Wrap your root application component with the MubarokahProvider. This provider initializes the authentication state and provides it to your entire component tree.
1. Configure the Provider
In your main.tsx or App.tsx:
import React from 'react';import { MubarokahProvider } from 'mubarokah-id-sdk/react';const config = { clientId: 'your-client-id', // clientSecret is NOT required for React apps (Public Client) redirectUri: 'http://localhost:3000/callback', baseUrl: 'https://accounts.mubarokah.com', // Optional: defaults to production};function App() { return ( <MubarokahProvider config={config}> <YourAppContent /> </MubarokahProvider> );}
2. Using the Hooks
The useMubarokahAuth hook gives you access to the user’s authentication state and methods to log in or out.
When the user approves the authentication request on Mubarokah ID, they are redirected back to your redirectUri. The SDK automatically detects the code and state parameters in the URL and completes the login flow.You don’t need to create a dedicated callback route unless you want custom logic; the MubarokahProvider handles this logic as soon as it mounts.
WhatsApp User Support
As mentioned in our WhatsApp Authentication Guide, users who register via WhatsApp will not have an email address.The SDK handles this gracefully:
user.email will be null.
user.id remains the unique, stable identifier for the user.
Pro Tip: Use the user?.id to map data in your frontend or backend rather than the email address.
Security Warning: Global Logout
Single Sign-Out Awareness
Calling logout() via the React Hook will terminate the user’s central session on the Mubarokah ID server. This means they will be logged out from all other Mubarokah ID apps too.It is recommended to show a confirmation dialog before calling logout().
Example with Confirmation:
const handleLogout = () => { if (window.confirm("Are you sure? This will log you out from all Mubarokah ID apps.")) { logout(); }};
Was this page helpful?
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Mubarokah ID Documentation","description":"Complete OAuth 2.0 integration guide and API reference for Mubarokah ID authentication service. Secure, scalable, and developer-friendly authentication for your applications.","colors":{"primary":"#0c0f3c","light":"#22a6f9","dark":"#566ef8"},"logo":{"light":"https://mubarokah-id-storage.s3.ap-southeast-3.amazonaws.com/assets/images/mubarokah-id-light.svg","dark":"https://mubarokah-id-storage.s3.ap-southeast-3.amazonaws.com/assets/images/mubarokah-id-dark.svg"},"favicon":"https://mubarokah-id-storage.s3.ap-southeast-3.amazonaws.com/assets/favicon/favicon-mubarokah-id.ico","api":{"playground":{"display":"interactive"},"examples":{"languages":["curl","javascript","python","php","java","go"]},"mdx":{"auth":{"method":"bearer"},"server":"https://accounts.mubarokah.com"}},"appearance":{"default":"system","strict":false},"navbar":{"links":[{"href":"https://s.id/023w4","label":"Support"}],"primary":{"type":"button","label":"Dashboard","href":"https://accounts.mubarokah.com/dashboard"}},"footer":{"socials":{"x":"https://x.com/mubarokah_id","facebook":"https://www.facebook.com/mubarokah.co.id","instagram":"https://www.instagram.com/mubarokahdotcom","linkedin":"https://www.linkedin.com/company/mubarokah","website":"https://mubarokah.com","youtube":"https://youtube.com/@mubarokahdigitalnusantara"},"links":[{"header":"Product","items":[{"label":"Web Development","href":"https://mubarokah.com/services/web-development"},{"label":"Mobile App Development","href":"https://mubarokah.com/services/mobile-app-development"},{"label":"Digital Marketing","href":"https://mubarokah.com/services/digital-marketing"},{"label":"View all our services","href":"https://mubarokah.com/services"},{"label":"See also our products","href":"https://mudin.myr.id/"}]},{"header":"Developers","items":[{"label":"Documentation","href":"https://accounts.mubarokah.com"},{"label":"API Reference","href":"https://accounts.mubarokah.com/guides/oauth-flow"},{"label":"Examples","href":"https://accounts.mubarokah.com/guides/framework-integration/laravel"}]},{"header":"Company","items":[{"label":"About Us","href":"https://mubarokah.com/about"},{"label":"Blog","href":"https://mubarokah.com/posts"},{"label":"Careers","href":"https://mubarokah.com/careers"},{"label":"Contact","href":"https://mubarokah.com/contact"},{"label":"Partnership Program","href":"https://partners.mubarokah.com/"}]},{"header":"Support","items":[{"label":"Help Center","href":"https://docs-accounts.mubarokah.com/kb/knowledgebase"},{"label":"Community","href":"https://chat.whatsapp.com/HQtyJMqfqq41KlrHLCvcFZ"},{"label":"Report Issue","href":"https://s.id/023w4"},{"label":"Privacy Policy","href":"https://mubarokah.com/privacy"},{"label":"System Status","href":"https://mdn.cronitorstatus.com/"}]}]},"search":{"prompt":"Search Mubarokah ID documentation..."},"seo":{"metatags":{"og:title":"Mubarokah ID Documentation - OAuth 2.0 Integration Guide","og:description":"Complete OAuth 2.0 integration guide and API reference for Mubarokah ID authentication service. Secure, scalable, and developer-friendly authentication.","og:image":"https://mubarokah-id-storage.s3.ap-southeast-3.amazonaws.com/assets/images/docs-og-image.png","og:url":"https://docs-accounts.mubarokah.com","og:type":"website","og:site_name":"Mubarokah ID Documentation","twitter:card":"summary_large_image","twitter:title":"Mubarokah ID Documentation","twitter:description":"Complete OAuth 2.0 integration guide and API reference for Mubarokah ID authentication service.","twitter:image":"https://mubarokah-id-storage.s3.ap-southeast-3.amazonaws.com/assets/images/docs-og-image.png","twitter:site":"@mubarokah_id","keywords":"OAuth 2.0, authentication, API, Mubarokah ID, login, SSO, single sign-on, security, integration guide","author":"Mubarokah","robots":"index, follow","canonical":"https://docs-accounts.mubarokah.com"},"indexing":"all"},"integrations":{"gtm":{"tagId":"GTM-5SNWGQ28"}},"contextual":{"options":["copy","view","chatgpt","claude"],"display":"header"},"styling":{"latex":false},"navigation":{"global":{"anchors":[{"anchor":"Community","icon":"whatsapp","href":"https://chat.whatsapp.com/HQtyJMqfqq41KlrHLCvcFZ"},{"anchor":"Blog","icon":"newspaper","href":"https://mubarokah.com/posts"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"ptmubarokahdigitalnusantara","hasAudioNarration":false,"actualSubdomain":"ptmubarokahdigitalnusantara","customDomains":["docs-accounts.mubarokah.com"],"gitSource":{"type":"github","owner":"abdillahmubarok","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"feedback":{"thumbs":true},"entitlements":{},"buildId":"6ae929bd64b0d57d799cf8b7:success","clientVersion":"0.0.4336","searchFilterCounts":[{"language":"default","tag":"API Reference","count":27},{"language":"default","tag":"Performance \u0026 Operations","count":10},{"language":"default","tag":"Guides","count":6},{"language":"default","tag":"Integration Guides","count":6},{"language":"default","tag":"Security","count":5},{"language":"default","tag":"Core Concepts","count":4},{"language":"default","tag":"Framework Examples","count":4},{"language":"default","tag":"OAuth Endpoints","count":3},{"language":"default","tag":"User API","count":2},{"language":"default","tag":"Getting Started","count":2}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"site-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"treatment","enabled":true,"payload":{"type":"string","value":"treatment"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"wildcard-email-auth","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"starterQuestions":[],"googleFontsInlined":false},"customCss":[]}
{"page":{"pagePath":"guides/framework-integration/react","slug":"/guides/framework-integration/react","pageMetadata":{"title":"React Integration","description":"Guide to integrating Mubarokah ID with a React application using the official SDK.","href":"/guides/framework-integration/react"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Guide to integrating Mubarokah ID with a React application using the official SDK.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,br:`br`,code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Tip,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Tip)_missingMdxReference(`Tip`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(Heading,{level:`1`,id:`react-integration-guide`,children:`React Integration Guide`}),`\n`,_jsx(_components.p,{children:`This guide explains how to integrate Mubarokah ID Single Sign-On into your React application using our official TypeScript SDK. The SDK provides a native React Context and Hooks designed for Single Page Applications (SPA), handles PKCE (Proof Key for Code Exchange) automatically, and manages session state.`}),`\n`,_jsx(Heading,{level:`2`,id:`installation`,children:`Installation`}),`\n`,_jsx(_components.p,{children:`Install the official SDK via npm:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` mubarokah-id-sdk`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`setup`,children:`Setup`}),`\n`,_jsxs(_components.p,{children:[`Wrap your root application component with the `,_jsx(_components.code,{children:`MubarokahProvider`}),`. This provider initializes the authentication state and provides it to your entire component tree.`]}),`\n`,_jsx(Heading,{level:`3`,id:`1-configure-the-provider`,children:`1. Configure the Provider`}),`\n`,_jsxs(_components.p,{children:[`In your `,_jsx(_components.code,{children:`main.tsx`}),` or `,_jsx(_components.code,{children:`App.tsx`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`17`,language:`tsx`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`tsx`,children:_jsxs(_components.code,{language:`tsx`,numberOfLines:`17`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` React`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'react'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`MubarokahProvider`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'mubarokah-id-sdk/react'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` config`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` clientId:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'your-client-id'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // clientSecret is NOT required for React apps (Public Client)`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` redirectUri:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'http://localhost:3000/callback'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` baseUrl:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'https://accounts.mubarokah.com'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Optional: defaults to production`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`};`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`function`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` App`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`() {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#4EC9B0`},children:`MubarokahProvider`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:` config`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`config`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#4EC9B0`},children:`YourAppContent`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` />`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#4EC9B0`},children:`MubarokahProvider`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` );`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`2-using-the-hooks`,children:`2. Using the Hooks`}),`\n`,_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`useMubarokahAuth`}),` hook gives you access to the user’s authentication state and methods to log in or out.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`33`,language:`tsx`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`tsx`,children:_jsxs(_components.code,{language:`tsx`,numberOfLines:`33`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`useMubarokahAuth`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'mubarokah-id-sdk/react'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`function`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` UserProfile`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`() {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` isAuthenticated`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` user`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` isLoading`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` loginWithRedirect`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` logout`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` useMubarokahAuth`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`isLoading`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`div`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`Loading authentication state...`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`div`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`isAuthenticated`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`div`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:` className`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"profile-card\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`img`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:` src`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`user`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`?.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`profile_picture`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:` alt`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`user`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`?.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`name`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` />`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`h2`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`Welcome, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`user`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`?.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`name`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`!`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`h2`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`p`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`Email: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`user`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`?.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`email`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` ||`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'Not provided (WhatsApp login)'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`p`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`button`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:` onClick`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`() `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` logout`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`Log Out`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`button`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`div`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` );`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`div`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:` className`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"login-container\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`h1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`Please Sign In`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`\u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`h1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`button`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:` onClick`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`() `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` loginWithRedirect`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Login with Mubarokah ID`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`button`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:` \u003c/`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#569CD6`},children:`div`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#808080`},children:`>`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` );`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`handling-the-callback`,children:`Handling the Callback`}),`\n`,_jsxs(_components.p,{children:[`When the user approves the authentication request on Mubarokah ID, they are redirected back to your `,_jsx(_components.code,{children:`redirectUri`}),`. The SDK automatically detects the `,_jsx(_components.code,{children:`code`}),` and `,_jsx(_components.code,{children:`state`}),` parameters in the URL and completes the login flow.`]}),`\n`,_jsxs(_components.p,{children:[`You don’t need to create a dedicated callback route unless you want custom logic; the `,_jsx(_components.code,{children:`MubarokahProvider`}),` handles this logic as soon as it mounts.`]}),`\n`,_jsx(Heading,{level:`2`,id:`whatsapp-user-support`,children:`WhatsApp User Support`}),`\n`,_jsxs(_components.p,{children:[`As mentioned in our `,_jsx(_components.a,{href:`/guides/whatsapp-authentication`,children:`WhatsApp Authentication Guide`}),`, users who register via WhatsApp will not have an email address.`]}),`\n`,_jsx(_components.p,{children:`The SDK handles this gracefully:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`user.email`}),` will be `,_jsx(_components.code,{children:`null`}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`user.id`}),` remains the unique, stable identifier for the user.`]}),`\n`]}),`\n`,_jsx(Tip,{children:_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Pro Tip`}),`: Use the `,_jsx(_components.code,{children:`user?.id`}),` to map data in your frontend or backend rather than the email address.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`security-warning-global-logout`,children:`Security Warning: Global Logout`}),`\n`,_jsxs(Warning,{children:[_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Single Sign-Out Awareness`}),_jsx(_components.br,{}),`\n`,`Calling `,_jsx(_components.code,{children:`logout()`}),` via the React Hook will terminate the user’s central session on the Mubarokah ID server. This means they will be logged out from `,_jsx(_components.strong,{children:`all`}),` other Mubarokah ID apps too.`]}),_jsxs(_components.p,{children:[`It is recommended to show a confirmation dialog before calling `,_jsx(_components.code,{children:`logout()`}),`.`]})]}),`\n`,_jsx(Heading,{level:`3`,id:`example-with-confirmation`,children:`Example with Confirmation:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`tsx`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`tsx`,children:_jsxs(_components.code,{language:`tsx`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` handleLogout`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` () `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`window`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`confirm`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Are you sure? This will log you out from all Mubarokah ID apps.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` logout`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`};`})}),`\n`]})})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"React Integration","description":"Guide to integrating Mubarokah ID with a React application using the official SDK.","href":"/guides/framework-integration/react"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"React Integration Guide","slug":"react-integration-guide","depth":1,"children":[]},{"title":"Installation","slug":"installation","depth":2,"children":[]},{"title":"Setup","slug":"setup","depth":2,"children":[{"title":"1. Configure the Provider","slug":"1-configure-the-provider","depth":3,"children":[]},{"title":"2. Using the Hooks","slug":"2-using-the-hooks","depth":3,"children":[]}]},{"title":"Handling the Callback","slug":"handling-the-callback","depth":2,"children":[]},{"title":"WhatsApp User Support","slug":"whatsapp-user-support","depth":2,"children":[]},{"title":"Security Warning: Global Logout","slug":"security-warning-global-logout","depth":2,"children":[{"title":"Example with Confirmation:","slug":"example-with-confirmation","depth":3,"children":[]}]}],"codeExamples":{}},"jsLinks":[],"subdomain":"ptmubarokahdigitalnusantara","siteName":"Mubarokah ID Documentation","title":"Mubarokah ID Documentation - OAuth 2.0 Integration Guide","contextualStarterQuestions":[],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-04-14T07:10:00.166Z","originalFileLocation":"guides/framework-integration/react.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Guide to integrating Mubarokah ID with a React application using the official SDK.\">\u003cmeta data-mint-head name=\"keywords\" content=\"OAuth 2.0, authentication, API, Mubarokah ID, login, SSO, single sign-on, security, integration guide\">\u003cmeta data-mint-head name=\"application-name\" content=\"Mubarokah ID Documentation\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003cmeta data-mint-head name=\"robots\" content=\"index, follow\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/x-icon\" sizes=\"180x180\" href=\"https://mubarokah-id-storage.s3.ap-southeast-3.amazonaws.com/assets/favicon/favicon-mubarokah-id.ico\">\u003clink data-mint-head rel=\"icon\" type=\"image/x-icon\" sizes=\"32x32\" href=\"https://mubarokah-id-storage.s3.ap-southeast-3.amazonaws.com/assets/favicon/favicon-mubarokah-id.ico\">\u003clink data-mint-head rel=\"icon\" type=\"image/x-icon\" sizes=\"16x16\" href=\"https://mubarokah-id-storage.s3.ap-southeast-3.amazonaws.com/assets/favicon/favicon-mubarokah-id.ico\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"https://mubarokah-id-storage.s3.ap-southeast-3.amazonaws.com/assets/favicon/favicon-mubarokah-id.ico\">\u003cmeta data-mint-head property=\"og:title\" content=\"Mubarokah ID Documentation - OAuth 2.0 Integration Guide\">\u003cmeta data-mint-head property=\"og:description\" content=\"Complete OAuth 2.0 integration guide and API reference for Mubarokah ID authentication service. Secure, scalable, and developer-friendly authentication.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Mubarokah ID Documentation\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs-accounts.mubarokah.com/guides/framework-integration/react\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://mubarokah-id-storage.s3.ap-southeast-3.amazonaws.com/assets/images/docs-og-image.png\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Mubarokah ID Documentation\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Complete OAuth 2.0 integration guide and API reference for Mubarokah ID authentication service.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://mubarokah-id-storage.s3.ap-southeast-3.amazonaws.com/assets/images/docs-og-image.png\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"https://mintlify.s3.us-west-1.amazonaws.com/ptmubarokahdigitalnusantara/_generated/favicon/browserconfig.xml?v=3\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Mubarokah ID Documentation\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#0c0f3c\">\u003cmeta data-mint-head name=\"author\" content=\"Mubarokah\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs-accounts.mubarokah.com/guides/framework-integration/react\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/guides/framework-integration/react.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs-accounts.mubarokah.com/#organization\",\"name\":\"Mubarokah ID Documentation\",\"url\":\"https://docs-accounts.mubarokah.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mubarokah-id-storage.s3.ap-southeast-3.amazonaws.com/assets/images/mubarokah-id-light.svg\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs-accounts.mubarokah.com#website\",\"name\":\"Mubarokah ID Documentation\",\"url\":\"https://docs-accounts.mubarokah.com\",\"publisher\":{\"@id\":\"https://docs-accounts.mubarokah.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs-accounts.mubarokah.com/guides/framework-integration/react#webpage\",\"url\":\"https://docs-accounts.mubarokah.com/guides/framework-integration/react\",\"name\":\"React Integration\",\"description\":\"Guide to integrating Mubarokah ID with a React application using the official SDK.\",\"dateModified\":\"2026-04-14T07:10:00.166Z\",\"isPartOf\":{\"@id\":\"https://docs-accounts.mubarokah.com#website\"},\"breadcrumb\":{\"@id\":\"https://docs-accounts.mubarokah.com/guides/framework-integration/react#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs-accounts.mubarokah.com/guides/framework-integration/react#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Integration Guides\",\"item\":\"https://docs-accounts.mubarokah.com/guides/oauth-flow\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Framework Examples\",\"item\":\"https://docs-accounts.mubarokah.com/guides/framework-integration/laravel\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"React Integration\",\"item\":\"https://docs-accounts.mubarokah.com/guides/framework-integration/react\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs-accounts.mubarokah.com/guides/framework-integration/react#article\",\"headline\":\"React Integration\",\"name\":\"React Integration\",\"description\":\"Guide to integrating Mubarokah ID with a React application using the official SDK.\",\"url\":\"https://docs-accounts.mubarokah.com/guides/framework-integration/react\",\"mainEntityOfPage\":{\"@id\":\"https://docs-accounts.mubarokah.com/guides/framework-integration/react#webpage\"},\"image\":\"https://mubarokah-id-storage.s3.ap-southeast-3.amazonaws.com/assets/images/docs-og-image.png\",\"dateModified\":\"2026-04-14T07:10:00.166Z\",\"publisher\":{\"@id\":\"https://docs-accounts.mubarokah.com/#organization\"},\"isPartOf\":{\"@id\":\"https://docs-accounts.mubarokah.com#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Mubarokah ID Documentation\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Mubarokah ID Documentation\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/guides/framework-integration/react.md","siteName":"Mubarokah ID Documentation","nav":{"global":{"anchors":[{"anchor":"Community","icon":"whatsapp","href":"https://chat.whatsapp.com/HQtyJMqfqq41KlrHLCvcFZ"},{"anchor":"Blog","icon":"newspaper","href":"https://mubarokah.com/posts"}]},"tabs":[{"tab":"Guides","pages":[{"title":"Guides","href":"/introduction"}]},{"tab":"API Reference","groups":[{"group":"Integration Guides","pages":[{"title":"OAuth 2.0 Flows","href":"/guides/oauth-flow"},{"title":"WhatsApp Authentication Flow","href":"/guides/whatsapp-authentication"},{"group":"Framework Examples","pages":[{"title":"Laravel (PHP) Integration","description":"Guide to integrating Mubarokah ID OAuth 2.0 with a Laravel application.","href":"/guides/framework-integration/laravel"},{"title":"React Integration","href":"/guides/framework-integration/react"},{"title":"Node.js (Express + TypeScript) Integration","description":"Guide to integrating Mubarokah ID OAuth 2.0 with a Node.js, Express, and TypeScript application.","href":"/guides/framework-integration/nodejs"},{"title":"Python (FastAPI) Integration","href":"/guides/framework-integration/python"}]}]},{"group":"OAuth Endpoints","pages":[{"title":"Authorization Endpoint","api":"GET /oauth/authorize","href":"/api-reference/oauth/authorize"},{"title":"Token Endpoint","api":"POST /oauth/token","href":"/api-reference/oauth/token"},{"title":"Global SSO Logout","api":"GET /api/logout-sso","href":"/api-reference/oauth/logout-sso"}]},{"group":"User API","pages":[{"title":"Get Basic User Information","api":"GET /api/user","href":"/api-reference/user/get-user-info"},{"title":"Get Detailed User Information","api":"GET /api/user/details","href":"/api-reference/user/get-user-details"}]},{"group":"Reference","pages":[{"title":"Error Codes","href":"/api-reference/error-codes"}]},{"group":"Security","pages":[{"title":"OAuth 2.0 Security Checklist","href":"/security/oauth-checklist"},{"title":"Token Security Best Practices","href":"/security/token-security"},{"title":"Input Validation and Sanitization","href":"/security/input-validation"},{"title":"Threat Model Analysis for OAuth Integrations","href":"/security/threat-modeling"},{"title":"Penetration Testing Guide for OAuth Integrations","href":"/security/penetration-testing"}]},{"group":"Performance \u0026 Operations","pages":[{"title":"Caching Strategies for OAuth Performance","href":"/performance/caching"},{"title":"Connection Optimization for API Calls","href":"/performance/connection-optimization"},{"title":"Unit Testing for OAuth Integrations","href":"/testing/unit-testing"},{"title":"Load Testing OAuth Integrations","href":"/testing/load-testing"},{"title":"Production Deployment Considerations","href":"/production/deployment"},{"title":"CI/CD Pipeline for OAuth Integrated Applications","href":"/production/ci-cd"},{"title":"Health Monitoring \u0026 Observability","href":"/production/health-monitoring"},{"title":"Error Resolution Framework","href":"/troubleshooting/error-resolution"},{"title":"Runbook Templates for Common OAuth Issues","href":"/troubleshooting/runbooks"},{"title":"Advanced Debugging for OAuth \u0026 API Integrations","href":"/operations/monitoring-debugging"}]}]},{"tab":"Knowledge Base","pages":[{"title":"Knowledge Base","href":"/kb/knowledgebase"}]}]},"basePath":"","title":"Mubarokah ID Documentation - OAuth 2.0 Integration Guide","deploymentId":"dpl_9bQLTw9nc2h9csDGYcKwWenPcQWn","buildId":"dpl_9bQLTw9nc2h9csDGYcKwWenPcQWn","dynamics":[],"chunks":[]}