@clerk/shared
Version:
Internal package utils used by the Clerk SDKs
50 lines • 1.59 kB
text/typescript
import { LoadedClerk } from "../../types/clerk.mjs";
//#region src/react/hooks/useClerk.d.ts
/**
* > [!WARNING]
* > This hook should only be used for advanced use cases, such as building a completely custom OAuth flow or as an escape hatch to access to the `Clerk` object.
*
* The `useClerk()` hook provides access to the [`Clerk`](https://clerk.com/docs/reference/objects/clerk) object, allowing you to build alternatives to any Clerk Component.
*
* @function
*
* @returns The `useClerk()` hook returns the `Clerk` object, which includes all the methods and properties listed in the [`Clerk` reference](https://clerk.com/docs/reference/objects/clerk).
*
* @example
*
* The following example uses the `useClerk()` hook to access the `clerk` object. The `clerk` object is used to call the [`openSignIn()`](https://clerk.com/docs/reference/objects/clerk#sign-in) method to open the sign-in modal.
*
* <Tabs items='React,Next.js'>
* <Tab>
*
* ```tsx {{ filename: 'src/Home.tsx' }}
* import { useClerk } from '@clerk/react'
*
* export default function Home() {
* const clerk = useClerk()
*
* return <button onClick={() => clerk.openSignIn({})}>Sign in</button>
* }
* ```
*
* </Tab>
* <Tab>
*
* ```tsx {{ filename: 'app/page.tsx' }}
* 'use client';
*
* import { useClerk } from '@clerk/nextjs';
*
* export default function HomePage() {
* const clerk = useClerk();
*
* return <button onClick={() => clerk.openSignIn({})}>Sign in</button>;
* }
* ```
*
* </Tab>
* </Tabs>
*/
declare const useClerk: () => LoadedClerk;
//#endregion
export { useClerk };