@clerk/react 6.3.0 → 6.4.0-snapshot.v20260413204347
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-YD67K53M.mjs → chunk-BBXSNLGY.mjs} +3 -3
- package/dist/{chunk-A7DRZKIX.mjs → chunk-MRQEENKP.mjs} +23 -1
- package/dist/chunk-MRQEENKP.mjs.map +1 -0
- package/dist/experimental.js +21 -0
- package/dist/experimental.js.map +1 -1
- package/dist/experimental.mjs +1 -1
- package/dist/index.d.mts +5 -157
- package/dist/index.d.ts +5 -157
- package/dist/index.js +22 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/internal.d.mts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +24 -1
- package/dist/internal.js.map +1 -1
- package/dist/internal.mjs +4 -2
- package/dist/internal.mjs.map +1 -1
- package/dist/useAuth-BbaIEAB3.d.mts +351 -0
- package/dist/useAuth-DFblXGN7.d.ts +351 -0
- package/package.json +4 -4
- package/dist/chunk-A7DRZKIX.mjs.map +0 -1
- package/dist/useAuth-BYiDKD-3.d.mts +0 -195
- package/dist/useAuth-DcwU7ADV.d.ts +0 -195
- /package/dist/{chunk-YD67K53M.mjs.map → chunk-BBXSNLGY.mjs.map} +0 -0
package/dist/internal.mjs
CHANGED
|
@@ -2,12 +2,13 @@ import {
|
|
|
2
2
|
ClerkProvider,
|
|
3
3
|
IS_REACT_SHARED_VARIANT_COMPATIBLE,
|
|
4
4
|
MultisessionAppSupport
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-BBXSNLGY.mjs";
|
|
6
6
|
import {
|
|
7
|
+
OAuthConsent,
|
|
7
8
|
incompatibleRoutingWithPathProvidedError,
|
|
8
9
|
noPathProvidedError,
|
|
9
10
|
useDerivedAuth
|
|
10
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-MRQEENKP.mjs";
|
|
11
12
|
import {
|
|
12
13
|
errorThrower,
|
|
13
14
|
setErrorThrowerOptions
|
|
@@ -57,6 +58,7 @@ export {
|
|
|
57
58
|
IS_REACT_SHARED_VARIANT_COMPATIBLE,
|
|
58
59
|
InternalClerkProvider,
|
|
59
60
|
MultisessionAppSupport,
|
|
61
|
+
OAuthConsent,
|
|
60
62
|
buildClerkJSScriptAttributes,
|
|
61
63
|
buildClerkJsScriptAttributes,
|
|
62
64
|
buildClerkUIScriptAttributes,
|
package/dist/internal.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internal.ts","../src/hooks/useRoutingProps.ts"],"sourcesContent":["import type { InternalClerkScriptProps } from '@clerk/shared/types';\nimport type { Ui } from '@clerk/ui/internal';\nimport type React from 'react';\n\nimport { ClerkProvider } from './contexts/ClerkProvider';\nimport type { ClerkProviderProps } from './types';\n\nexport { setErrorThrowerOptions } from './errors/errorThrower';\nexport { MultisessionAppSupport } from './components/controlComponents';\nexport { useOAuthConsent } from '@clerk/shared/react';\nexport { useRoutingProps } from './hooks/useRoutingProps';\nexport { useDerivedAuth } from './hooks/useAuth';\nexport { IS_REACT_SHARED_VARIANT_COMPATIBLE } from './utils/versionCheck';\n\nexport {\n clerkJSScriptUrl,\n buildClerkJSScriptAttributes,\n clerkUIScriptUrl,\n buildClerkUIScriptAttributes,\n setClerkJSLoadingErrorPackageName,\n // Deprecated aliases - will be removed in a future major version\n clerkJsScriptUrl,\n buildClerkJsScriptAttributes,\n setClerkJsLoadingErrorPackageName,\n} from '@clerk/shared/loadClerkJsScript';\n\nexport type { Ui } from '@clerk/ui/internal';\n\nexport type { InternalClerkScriptProps } from '@clerk/shared/types';\n\n/**\n * A wider-typed version of ClerkProvider that accepts internal script props.\n * Framework SDKs should use this instead of the public ClerkProvider.\n */\nexport const InternalClerkProvider = ClerkProvider as unknown as (<TUi extends Ui = Ui>(\n props: ClerkProviderProps<TUi> & InternalClerkScriptProps,\n) => React.JSX.Element) & { displayName: string };\n","import type { RoutingOptions } from '@clerk/shared/types';\n\nimport { errorThrower } from '../errors/errorThrower';\nimport { incompatibleRoutingWithPathProvidedError, noPathProvidedError } from '../errors/messages';\n\nexport function useRoutingProps<T extends RoutingOptions>(\n componentName: string,\n props: T,\n routingOptions?: RoutingOptions,\n): T {\n const path = props.path || routingOptions?.path;\n const routing = props.routing || routingOptions?.routing || 'path';\n\n if (routing === 'path') {\n if (!path) {\n return errorThrower.throw(noPathProvidedError(componentName));\n }\n\n return {\n ...routingOptions,\n ...props,\n routing: 'path',\n };\n }\n\n if (props.path) {\n return errorThrower.throw(incompatibleRoutingWithPathProvidedError(componentName));\n }\n\n return {\n ...routingOptions,\n ...props,\n path: undefined,\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/internal.ts","../src/hooks/useRoutingProps.ts"],"sourcesContent":["import type { InternalClerkScriptProps } from '@clerk/shared/types';\nimport type { Ui } from '@clerk/ui/internal';\nimport type React from 'react';\n\nimport { ClerkProvider } from './contexts/ClerkProvider';\nimport type { ClerkProviderProps } from './types';\n\nexport { setErrorThrowerOptions } from './errors/errorThrower';\nexport { MultisessionAppSupport } from './components/controlComponents';\nexport { useOAuthConsent } from '@clerk/shared/react';\nexport { OAuthConsent } from './components/uiComponents';\nexport { useRoutingProps } from './hooks/useRoutingProps';\nexport { useDerivedAuth } from './hooks/useAuth';\nexport { IS_REACT_SHARED_VARIANT_COMPATIBLE } from './utils/versionCheck';\n\nexport {\n clerkJSScriptUrl,\n buildClerkJSScriptAttributes,\n clerkUIScriptUrl,\n buildClerkUIScriptAttributes,\n setClerkJSLoadingErrorPackageName,\n // Deprecated aliases - will be removed in a future major version\n clerkJsScriptUrl,\n buildClerkJsScriptAttributes,\n setClerkJsLoadingErrorPackageName,\n} from '@clerk/shared/loadClerkJsScript';\n\nexport type { Ui } from '@clerk/ui/internal';\n\nexport type { InternalClerkScriptProps } from '@clerk/shared/types';\n\n/**\n * A wider-typed version of ClerkProvider that accepts internal script props.\n * Framework SDKs should use this instead of the public ClerkProvider.\n */\nexport const InternalClerkProvider = ClerkProvider as unknown as (<TUi extends Ui = Ui>(\n props: ClerkProviderProps<TUi> & InternalClerkScriptProps,\n) => React.JSX.Element) & { displayName: string };\n","import type { RoutingOptions } from '@clerk/shared/types';\n\nimport { errorThrower } from '../errors/errorThrower';\nimport { incompatibleRoutingWithPathProvidedError, noPathProvidedError } from '../errors/messages';\n\nexport function useRoutingProps<T extends RoutingOptions>(\n componentName: string,\n props: T,\n routingOptions?: RoutingOptions,\n): T {\n const path = props.path || routingOptions?.path;\n const routing = props.routing || routingOptions?.routing || 'path';\n\n if (routing === 'path') {\n if (!path) {\n return errorThrower.throw(noPathProvidedError(componentName));\n }\n\n return {\n ...routingOptions,\n ...props,\n routing: 'path',\n };\n }\n\n if (props.path) {\n return errorThrower.throw(incompatibleRoutingWithPathProvidedError(componentName));\n }\n\n return {\n ...routingOptions,\n ...props,\n path: undefined,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AASA,SAAS,uBAAuB;;;ACJzB,SAAS,gBACd,eACA,OACA,gBACG;AACH,QAAM,OAAO,MAAM,SAAQ,iDAAgB;AAC3C,QAAM,UAAU,MAAM,YAAW,iDAAgB,YAAW;AAE5D,MAAI,YAAY,QAAQ;AACtB,QAAI,CAAC,MAAM;AACT,aAAO,aAAa,MAAM,oBAAoB,aAAa,CAAC;AAAA,IAC9D;AAEA,WAAO;AAAA,MACL,GAAG;AAAA,MACH,GAAG;AAAA,MACH,SAAS;AAAA,IACX;AAAA,EACF;AAEA,MAAI,MAAM,MAAM;AACd,WAAO,aAAa,MAAM,yCAAyC,aAAa,CAAC;AAAA,EACnF;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,GAAG;AAAA,IACH,MAAM;AAAA,EACR;AACF;;;ADnBA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAUA,IAAM,wBAAwB;","names":[]}
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import * as _clerk_shared_types from '@clerk/shared/types';
|
|
2
|
+
import { Without, APIKeysProps, CreateOrganizationProps, OrganizationListProps, OrganizationProfileProps, OrganizationSwitcherProps, SignInProps, SignUpProps, TaskChooseOrganizationProps, TaskResetPasswordProps, TaskSetupMFAProps, UserAvatarProps, UserButtonProps, UserProfileProps, WaitlistProps, __internal_OAuthConsentProps, HandleOAuthCallbackParams, ShowWhenCondition, PendingSessionOptions, UseAuthReturn } from '@clerk/shared/types';
|
|
3
|
+
import React, { ReactNode, PropsWithChildren } from 'react';
|
|
4
|
+
import { WithClerkProp, OrganizationProfilePageProps, OrganizationProfileLinkProps, UserProfilePageProps, UserProfileLinkProps, UserButtonActionProps, UserButtonLinkProps } from './types.mjs';
|
|
5
|
+
|
|
6
|
+
type FallbackProp = {
|
|
7
|
+
/**
|
|
8
|
+
* An optional element to render while the component is mounting.
|
|
9
|
+
*/
|
|
10
|
+
fallback?: ReactNode;
|
|
11
|
+
};
|
|
12
|
+
type UserProfileExportType = typeof _UserProfile & {
|
|
13
|
+
Page: typeof UserProfilePage;
|
|
14
|
+
Link: typeof UserProfileLink;
|
|
15
|
+
};
|
|
16
|
+
type UserButtonExportType = typeof _UserButton & {
|
|
17
|
+
UserProfilePage: typeof UserProfilePage;
|
|
18
|
+
UserProfileLink: typeof UserProfileLink;
|
|
19
|
+
MenuItems: typeof MenuItems;
|
|
20
|
+
Action: typeof MenuAction;
|
|
21
|
+
Link: typeof MenuLink;
|
|
22
|
+
/**
|
|
23
|
+
* The `<Outlet />` component can be used in conjunction with `asProvider` in order to control rendering
|
|
24
|
+
* of the `<UserButton />` without affecting its configuration or any custom pages that could be mounted
|
|
25
|
+
* @experimental This API is experimental and may change at any moment.
|
|
26
|
+
*/
|
|
27
|
+
__experimental_Outlet: typeof UserButtonOutlet;
|
|
28
|
+
};
|
|
29
|
+
type UserButtonPropsWithoutCustomPages = Without<UserButtonProps, 'userProfileProps' | '__experimental_asStandalone'> & {
|
|
30
|
+
userProfileProps?: Pick<UserProfileProps, 'additionalOAuthScopes' | 'appearance' | 'apiKeysProps'>;
|
|
31
|
+
/**
|
|
32
|
+
* Adding `asProvider` will defer rendering until the `<Outlet />` component is mounted.
|
|
33
|
+
*
|
|
34
|
+
* @experimental This API is experimental and may change at any moment.
|
|
35
|
+
* @default undefined
|
|
36
|
+
*/
|
|
37
|
+
__experimental_asProvider?: boolean;
|
|
38
|
+
};
|
|
39
|
+
type OrganizationProfileExportType = typeof _OrganizationProfile & {
|
|
40
|
+
Page: typeof OrganizationProfilePage;
|
|
41
|
+
Link: typeof OrganizationProfileLink;
|
|
42
|
+
};
|
|
43
|
+
type OrganizationSwitcherExportType = typeof _OrganizationSwitcher & {
|
|
44
|
+
OrganizationProfilePage: typeof OrganizationProfilePage;
|
|
45
|
+
OrganizationProfileLink: typeof OrganizationProfileLink;
|
|
46
|
+
/**
|
|
47
|
+
* The `<Outlet />` component can be used in conjunction with `asProvider` in order to control rendering
|
|
48
|
+
* of the `<OrganizationSwitcher />` without affecting its configuration or any custom pages that could be mounted
|
|
49
|
+
*
|
|
50
|
+
* @experimental This API is experimental and may change at any moment.
|
|
51
|
+
*/
|
|
52
|
+
__experimental_Outlet: typeof OrganizationSwitcherOutlet;
|
|
53
|
+
};
|
|
54
|
+
type OrganizationSwitcherPropsWithoutCustomPages = Without<OrganizationSwitcherProps, 'organizationProfileProps' | '__experimental_asStandalone'> & {
|
|
55
|
+
organizationProfileProps?: Pick<OrganizationProfileProps, 'appearance'>;
|
|
56
|
+
/**
|
|
57
|
+
* Adding `asProvider` will defer rendering until the `<Outlet />` component is mounted.
|
|
58
|
+
*
|
|
59
|
+
* @experimental This API is experimental and may change at any moment.
|
|
60
|
+
* @default undefined
|
|
61
|
+
*/
|
|
62
|
+
__experimental_asProvider?: boolean;
|
|
63
|
+
};
|
|
64
|
+
declare const SignIn: {
|
|
65
|
+
(props: Without<WithClerkProp<SignInProps & FallbackProp>, "clerk">): React.JSX.Element | null;
|
|
66
|
+
displayName: string;
|
|
67
|
+
};
|
|
68
|
+
declare const SignUp: {
|
|
69
|
+
(props: Without<WithClerkProp<SignUpProps & FallbackProp>, "clerk">): React.JSX.Element | null;
|
|
70
|
+
displayName: string;
|
|
71
|
+
};
|
|
72
|
+
declare function UserProfilePage({ children }: PropsWithChildren<UserProfilePageProps>): React.JSX.Element;
|
|
73
|
+
declare function UserProfileLink({ children }: PropsWithChildren<UserProfileLinkProps>): React.JSX.Element;
|
|
74
|
+
declare const _UserProfile: {
|
|
75
|
+
(props: Without<WithClerkProp<PropsWithChildren<Without<UserProfileProps, "customPages">> & FallbackProp>, "clerk">): React.JSX.Element | null;
|
|
76
|
+
displayName: string;
|
|
77
|
+
};
|
|
78
|
+
declare const UserProfile: UserProfileExportType;
|
|
79
|
+
declare const _UserButton: {
|
|
80
|
+
(props: Without<WithClerkProp<PropsWithChildren<UserButtonPropsWithoutCustomPages> & FallbackProp>, "clerk">): React.JSX.Element | null;
|
|
81
|
+
displayName: string;
|
|
82
|
+
};
|
|
83
|
+
declare function MenuItems({ children }: PropsWithChildren): React.JSX.Element;
|
|
84
|
+
declare function MenuAction({ children }: PropsWithChildren<UserButtonActionProps>): React.JSX.Element;
|
|
85
|
+
declare function MenuLink({ children }: PropsWithChildren<UserButtonLinkProps>): React.JSX.Element;
|
|
86
|
+
declare function UserButtonOutlet(outletProps: Without<UserButtonProps, 'userProfileProps'>): React.JSX.Element;
|
|
87
|
+
declare const UserButton: UserButtonExportType;
|
|
88
|
+
declare function OrganizationProfilePage({ children }: PropsWithChildren<OrganizationProfilePageProps>): React.JSX.Element;
|
|
89
|
+
declare function OrganizationProfileLink({ children }: PropsWithChildren<OrganizationProfileLinkProps>): React.JSX.Element;
|
|
90
|
+
declare const _OrganizationProfile: {
|
|
91
|
+
(props: Without<WithClerkProp<PropsWithChildren<Without<OrganizationProfileProps, "customPages">> & FallbackProp>, "clerk">): React.JSX.Element | null;
|
|
92
|
+
displayName: string;
|
|
93
|
+
};
|
|
94
|
+
declare const OrganizationProfile: OrganizationProfileExportType;
|
|
95
|
+
declare const CreateOrganization: {
|
|
96
|
+
(props: Without<WithClerkProp<CreateOrganizationProps & FallbackProp>, "clerk">): React.JSX.Element | null;
|
|
97
|
+
displayName: string;
|
|
98
|
+
};
|
|
99
|
+
declare const _OrganizationSwitcher: {
|
|
100
|
+
(props: Without<WithClerkProp<PropsWithChildren<OrganizationSwitcherPropsWithoutCustomPages> & FallbackProp>, "clerk">): React.JSX.Element | null;
|
|
101
|
+
displayName: string;
|
|
102
|
+
};
|
|
103
|
+
declare function OrganizationSwitcherOutlet(outletProps: Without<OrganizationSwitcherProps, 'organizationProfileProps'>): React.JSX.Element;
|
|
104
|
+
declare const OrganizationSwitcher: OrganizationSwitcherExportType;
|
|
105
|
+
declare const OrganizationList: {
|
|
106
|
+
(props: Without<WithClerkProp<OrganizationListProps & FallbackProp>, "clerk">): React.JSX.Element | null;
|
|
107
|
+
displayName: string;
|
|
108
|
+
};
|
|
109
|
+
declare const GoogleOneTap: {
|
|
110
|
+
(props: Without<WithClerkProp<_clerk_shared_types.SignInForceRedirectUrl & _clerk_shared_types.SignUpForceRedirectUrl & {
|
|
111
|
+
cancelOnTapOutside?: boolean;
|
|
112
|
+
itpSupport?: boolean;
|
|
113
|
+
fedCmSupport?: boolean;
|
|
114
|
+
appearance?: _clerk_shared_types.ClerkAppearanceTheme;
|
|
115
|
+
} & FallbackProp>, "clerk">): React.JSX.Element | null;
|
|
116
|
+
displayName: string;
|
|
117
|
+
};
|
|
118
|
+
declare const Waitlist: {
|
|
119
|
+
(props: Without<WithClerkProp<WaitlistProps & FallbackProp>, "clerk">): React.JSX.Element | null;
|
|
120
|
+
displayName: string;
|
|
121
|
+
};
|
|
122
|
+
declare const PricingTable: {
|
|
123
|
+
(props: Without<WithClerkProp<{
|
|
124
|
+
for?: _clerk_shared_types.ForPayerType;
|
|
125
|
+
appearance?: _clerk_shared_types.ClerkAppearanceTheme;
|
|
126
|
+
checkoutProps?: Pick<_clerk_shared_types.__internal_CheckoutProps, "appearance">;
|
|
127
|
+
} & {
|
|
128
|
+
ctaPosition?: "top" | "bottom";
|
|
129
|
+
collapseFeatures?: boolean;
|
|
130
|
+
newSubscriptionRedirectUrl?: string;
|
|
131
|
+
} & FallbackProp>, "clerk">): React.JSX.Element | null;
|
|
132
|
+
displayName: string;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* @experimental This component is in early access and may change in future releases.
|
|
136
|
+
*/
|
|
137
|
+
declare const APIKeys: {
|
|
138
|
+
(props: Without<WithClerkProp<APIKeysProps & FallbackProp>, "clerk">): React.JSX.Element | null;
|
|
139
|
+
displayName: string;
|
|
140
|
+
};
|
|
141
|
+
declare const OAuthConsent: {
|
|
142
|
+
(props: Without<WithClerkProp<__internal_OAuthConsentProps & FallbackProp>, "clerk">): React.JSX.Element | null;
|
|
143
|
+
displayName: string;
|
|
144
|
+
};
|
|
145
|
+
declare const UserAvatar: {
|
|
146
|
+
(props: Without<WithClerkProp<UserAvatarProps & FallbackProp>, "clerk">): React.JSX.Element | null;
|
|
147
|
+
displayName: string;
|
|
148
|
+
};
|
|
149
|
+
declare const TaskChooseOrganization: {
|
|
150
|
+
(props: Without<WithClerkProp<TaskChooseOrganizationProps & FallbackProp>, "clerk">): React.JSX.Element | null;
|
|
151
|
+
displayName: string;
|
|
152
|
+
};
|
|
153
|
+
declare const TaskResetPassword: {
|
|
154
|
+
(props: Without<WithClerkProp<TaskResetPasswordProps & FallbackProp>, "clerk">): React.JSX.Element | null;
|
|
155
|
+
displayName: string;
|
|
156
|
+
};
|
|
157
|
+
declare const TaskSetupMFA: {
|
|
158
|
+
(props: Without<WithClerkProp<TaskSetupMFAProps & FallbackProp>, "clerk">): React.JSX.Element | null;
|
|
159
|
+
displayName: string;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
declare const ClerkLoaded: ({ children }: React.PropsWithChildren<unknown>) => React.ReactNode;
|
|
163
|
+
declare const ClerkLoading: ({ children }: React.PropsWithChildren<unknown>) => React.ReactNode;
|
|
164
|
+
declare const ClerkFailed: ({ children }: React.PropsWithChildren<unknown>) => React.ReactNode;
|
|
165
|
+
declare const ClerkDegraded: ({ children }: React.PropsWithChildren<unknown>) => React.ReactNode;
|
|
166
|
+
type ShowProps = React.PropsWithChildren<{
|
|
167
|
+
fallback?: React.ReactNode;
|
|
168
|
+
when: ShowWhenCondition;
|
|
169
|
+
} & PendingSessionOptions>;
|
|
170
|
+
/**
|
|
171
|
+
* Use `<Show/>` to conditionally render content based on user authorization or sign-in state.
|
|
172
|
+
* Returns `null` while auth is loading. Set `treatPendingAsSignedOut` to treat
|
|
173
|
+
* pending sessions as signed out during that period.
|
|
174
|
+
*
|
|
175
|
+
* The `when` prop supports:
|
|
176
|
+
* - `"signed-in"` or `"signed-out"` shorthands
|
|
177
|
+
* - Authorization descriptors (e.g., `{ permission: "org:billing:manage" }`, `{ role: "admin" }`)
|
|
178
|
+
* - A predicate function `(has) => boolean` that receives the `has` helper
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```tsx
|
|
182
|
+
* <Show when={{ permission: "org:billing:manage" }} fallback={<p>Unauthorized</p>}>
|
|
183
|
+
* <BillingSettings />
|
|
184
|
+
* </Show>
|
|
185
|
+
*
|
|
186
|
+
* <Show when={{ role: "admin" }}>
|
|
187
|
+
* <AdminPanel />
|
|
188
|
+
* </Show>
|
|
189
|
+
*
|
|
190
|
+
* <Show when={(has) => has({ permission: "org:read" }) && isFeatureEnabled}>
|
|
191
|
+
* <ProtectedFeature />
|
|
192
|
+
* </Show>
|
|
193
|
+
* ```
|
|
194
|
+
*
|
|
195
|
+
*/
|
|
196
|
+
declare const Show: ({ children, fallback, treatPendingAsSignedOut, when }: ShowProps) => React.ReactNode;
|
|
197
|
+
declare const RedirectToSignIn: {
|
|
198
|
+
(props: _clerk_shared_types.Without<WithClerkProp<_clerk_shared_types.SignInRedirectOptions>, "clerk">): React.JSX.Element | null;
|
|
199
|
+
displayName: string;
|
|
200
|
+
};
|
|
201
|
+
declare const RedirectToSignUp: {
|
|
202
|
+
(props: _clerk_shared_types.Without<WithClerkProp<_clerk_shared_types.SignUpRedirectOptions>, "clerk">): React.JSX.Element | null;
|
|
203
|
+
displayName: string;
|
|
204
|
+
};
|
|
205
|
+
declare const RedirectToTasks: {
|
|
206
|
+
(props: _clerk_shared_types.Without<WithClerkProp<_clerk_shared_types.TasksRedirectOptions>, "clerk">): React.JSX.Element | null;
|
|
207
|
+
displayName: string;
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* @function
|
|
211
|
+
* @deprecated Use [`redirectToUserProfile()`](https://clerk.com/docs/reference/objects/clerk#redirect-to-user-profile) instead.
|
|
212
|
+
*/
|
|
213
|
+
declare const RedirectToUserProfile: {
|
|
214
|
+
(props: _clerk_shared_types.Without<{
|
|
215
|
+
clerk: _clerk_shared_types.LoadedClerk;
|
|
216
|
+
component?: string;
|
|
217
|
+
}, "clerk">): React.JSX.Element | null;
|
|
218
|
+
displayName: string;
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* @function
|
|
222
|
+
* @deprecated Use [`redirectToOrganizationProfile()`](https://clerk.com/docs/reference/objects/clerk#redirect-to-organization-profile) instead.
|
|
223
|
+
*/
|
|
224
|
+
declare const RedirectToOrganizationProfile: {
|
|
225
|
+
(props: _clerk_shared_types.Without<{
|
|
226
|
+
clerk: _clerk_shared_types.LoadedClerk;
|
|
227
|
+
component?: string;
|
|
228
|
+
}, "clerk">): React.JSX.Element | null;
|
|
229
|
+
displayName: string;
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* @function
|
|
233
|
+
* @deprecated Use [`redirectToCreateOrganization()`](https://clerk.com/docs/reference/objects/clerk#redirect-to-create-organization) instead.
|
|
234
|
+
*/
|
|
235
|
+
declare const RedirectToCreateOrganization: {
|
|
236
|
+
(props: _clerk_shared_types.Without<{
|
|
237
|
+
clerk: _clerk_shared_types.LoadedClerk;
|
|
238
|
+
component?: string;
|
|
239
|
+
}, "clerk">): React.JSX.Element | null;
|
|
240
|
+
displayName: string;
|
|
241
|
+
};
|
|
242
|
+
declare const AuthenticateWithRedirectCallback: {
|
|
243
|
+
(props: _clerk_shared_types.Without<WithClerkProp<HandleOAuthCallbackParams>, "clerk">): React.JSX.Element | null;
|
|
244
|
+
displayName: string;
|
|
245
|
+
};
|
|
246
|
+
declare const MultisessionAppSupport: ({ children }: React.PropsWithChildren<unknown>) => React.JSX.Element;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* @inline
|
|
250
|
+
*/
|
|
251
|
+
type UseAuthOptions = PendingSessionOptions | undefined | null;
|
|
252
|
+
/**
|
|
253
|
+
* The `useAuth()` hook provides access to the current user's authentication state and methods to manage the active session.
|
|
254
|
+
*
|
|
255
|
+
* > [!NOTE]
|
|
256
|
+
* > To access auth data server-side, see the [`Auth` object reference doc](https://clerk.com/docs/reference/backend/types/auth-object).
|
|
257
|
+
*
|
|
258
|
+
* <If sdk="nextjs">
|
|
259
|
+
* By default, Next.js opts all routes into static rendering. If you need to opt a route or routes into dynamic rendering because you need to access the authentication data at request time, you can create a boundary by passing the `dynamic` prop to `<ClerkProvider>`. See the [guide on rendering modes](https://clerk.com/docs/guides/development/rendering-modes) for more information, including code examples.
|
|
260
|
+
* </If>
|
|
261
|
+
*
|
|
262
|
+
* @unionReturnHeadings
|
|
263
|
+
* ["Initialization", "Signed out", "Signed in (no active organization)", "Signed in (with active organization)"]
|
|
264
|
+
*
|
|
265
|
+
* @param [options] - An object containing options for the `useAuth()` hook. `treatPendingAsSignedOut` is a boolean that indicates whether pending sessions are considered as signed out or not. Defaults to `true`.
|
|
266
|
+
*
|
|
267
|
+
* @function
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
*
|
|
271
|
+
* The following example demonstrates how to use the `useAuth()` hook to access the current auth state, like whether the user is signed in or not. It also includes a basic example for using the `getToken()` method to retrieve a session token for fetching data from an external resource.
|
|
272
|
+
*
|
|
273
|
+
* <Tabs items='React,Next.js'>
|
|
274
|
+
* <Tab>
|
|
275
|
+
*
|
|
276
|
+
* ```tsx {{ filename: 'src/pages/ExternalDataPage.tsx' }}
|
|
277
|
+
* import { useAuth } from '@clerk/react'
|
|
278
|
+
*
|
|
279
|
+
* export default function ExternalDataPage() {
|
|
280
|
+
* const { userId, sessionId, getToken, isLoaded, isSignedIn } = useAuth()
|
|
281
|
+
*
|
|
282
|
+
* const fetchExternalData = async () => {
|
|
283
|
+
* const token = await getToken()
|
|
284
|
+
*
|
|
285
|
+
* // Fetch data from an external API
|
|
286
|
+
* const response = await fetch('https://api.example.com/data', {
|
|
287
|
+
* headers: {
|
|
288
|
+
* Authorization: `Bearer ${token}`,
|
|
289
|
+
* },
|
|
290
|
+
* })
|
|
291
|
+
*
|
|
292
|
+
* return response.json()
|
|
293
|
+
* }
|
|
294
|
+
*
|
|
295
|
+
* if (!isLoaded) {
|
|
296
|
+
* return <div>Loading...</div>
|
|
297
|
+
* }
|
|
298
|
+
*
|
|
299
|
+
* if (!isSignedIn) {
|
|
300
|
+
* return <div>Sign in to view this page</div>
|
|
301
|
+
* }
|
|
302
|
+
*
|
|
303
|
+
* return (
|
|
304
|
+
* <div>
|
|
305
|
+
* <p>
|
|
306
|
+
* Hello, {userId}! Your current active session is {sessionId}.
|
|
307
|
+
* </p>
|
|
308
|
+
* <button onClick={fetchExternalData}>Fetch Data</button>
|
|
309
|
+
* </div>
|
|
310
|
+
* )
|
|
311
|
+
* }
|
|
312
|
+
* ```
|
|
313
|
+
*
|
|
314
|
+
* </Tab>
|
|
315
|
+
* <Tab>
|
|
316
|
+
*
|
|
317
|
+
* {@include ../../docs/use-auth.md#nextjs-01}
|
|
318
|
+
*
|
|
319
|
+
* </Tab>
|
|
320
|
+
* </Tabs>
|
|
321
|
+
*/
|
|
322
|
+
declare const useAuth: (options?: UseAuthOptions) => UseAuthReturn;
|
|
323
|
+
/**
|
|
324
|
+
* A hook that derives and returns authentication state and utility functions based on the provided auth object.
|
|
325
|
+
*
|
|
326
|
+
* @param authObject - An object containing authentication-related properties and functions.
|
|
327
|
+
*
|
|
328
|
+
* @returns A derived authentication state with helper methods. If the authentication state is invalid, an error is thrown.
|
|
329
|
+
*
|
|
330
|
+
* @remarks
|
|
331
|
+
* This hook inspects session, user, and organization information to determine the current authentication state.
|
|
332
|
+
* It returns an object that includes various properties such as whether the state is loaded, if a user is signed in,
|
|
333
|
+
* session and user identifiers, Organization Roles, and a `has` function for authorization checks.
|
|
334
|
+
* Additionally, it provides `signOut` and `getToken` functions if applicable.
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* ```tsx
|
|
338
|
+
* const {
|
|
339
|
+
* isLoaded,
|
|
340
|
+
* isSignedIn,
|
|
341
|
+
* userId,
|
|
342
|
+
* orgId,
|
|
343
|
+
* has,
|
|
344
|
+
* signOut,
|
|
345
|
+
* getToken
|
|
346
|
+
* } = useDerivedAuth(authObject);
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
declare function useDerivedAuth(authObject: any, { treatPendingAsSignedOut }?: PendingSessionOptions): UseAuthReturn;
|
|
350
|
+
|
|
351
|
+
export { APIKeys as A, CreateOrganization as C, GoogleOneTap as G, MultisessionAppSupport as M, OAuthConsent as O, PricingTable as P, RedirectToCreateOrganization as R, SignIn as S, TaskChooseOrganization as T, UserAvatar as U, Waitlist as W, OrganizationList as a, OrganizationProfile as b, OrganizationSwitcher as c, SignUp as d, TaskResetPassword as e, TaskSetupMFA as f, UserButton as g, UserProfile as h, AuthenticateWithRedirectCallback as i, ClerkDegraded as j, ClerkFailed as k, ClerkLoaded as l, ClerkLoading as m, RedirectToOrganizationProfile as n, RedirectToSignIn as o, RedirectToSignUp as p, RedirectToTasks as q, RedirectToUserProfile as r, Show as s, type ShowProps as t, useDerivedAuth as u, useAuth as v };
|