@ory/elements-react 1.0.0-next.17 → 1.0.0-next.18

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.
Files changed (61) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/api-report/elements-react-client.api.json +144 -16
  3. package/api-report/elements-react-client.api.md +19 -8
  4. package/api-report/elements-react-theme.api.json +47 -0
  5. package/api-report/elements-react-theme.api.md +5 -2
  6. package/api-report/elements-react.api.json +7 -3
  7. package/api-report/elements-react.api.md +4 -2
  8. package/api-report/temp/elements-react-client.api.md +19 -8
  9. package/api-report/temp/elements-react-theme.api.md +5 -2
  10. package/api-report/temp/elements-react.api.md +4 -2
  11. package/dist/client/config.d.mts +21 -0
  12. package/dist/client/config.d.ts +21 -0
  13. package/dist/client/config.js +77 -0
  14. package/dist/client/config.js.map +1 -0
  15. package/dist/client/config.mjs +51 -0
  16. package/dist/client/config.mjs.map +1 -0
  17. package/dist/client/frontendClient.d.mts +3 -1
  18. package/dist/client/frontendClient.d.ts +3 -1
  19. package/dist/client/frontendClient.js +14 -2
  20. package/dist/client/frontendClient.js.map +1 -1
  21. package/dist/client/frontendClient.mjs +14 -2
  22. package/dist/client/frontendClient.mjs.map +1 -1
  23. package/dist/client/index.d.mts +3 -1
  24. package/dist/client/index.d.ts +3 -1
  25. package/dist/client/index.js +4 -0
  26. package/dist/client/index.js.map +1 -1
  27. package/dist/client/index.mjs +5 -0
  28. package/dist/client/index.mjs.map +1 -1
  29. package/dist/client/session-provider.d.mts +62 -0
  30. package/dist/client/session-provider.d.ts +62 -0
  31. package/dist/client/session-provider.js +96 -0
  32. package/dist/client/session-provider.js.map +1 -0
  33. package/dist/client/session-provider.mjs +71 -0
  34. package/dist/client/session-provider.mjs.map +1 -0
  35. package/dist/client/useSession.d.mts +22 -31
  36. package/dist/client/useSession.d.ts +22 -31
  37. package/dist/client/useSession.js +7 -49
  38. package/dist/client/useSession.js.map +1 -1
  39. package/dist/client/useSession.mjs +8 -49
  40. package/dist/client/useSession.mjs.map +1 -1
  41. package/dist/index.d.mts +5 -4
  42. package/dist/index.d.ts +5 -4
  43. package/dist/index.js +46 -24
  44. package/dist/index.js.map +1 -1
  45. package/dist/index.mjs +49 -27
  46. package/dist/index.mjs.map +1 -1
  47. package/dist/theme/default/index.css +358 -251
  48. package/dist/theme/default/index.css.map +1 -1
  49. package/dist/theme/default/index.d.mts +4 -2
  50. package/dist/theme/default/index.d.ts +4 -2
  51. package/dist/theme/default/index.js +605 -531
  52. package/dist/theme/default/index.js.map +1 -1
  53. package/dist/theme/default/index.mjs +536 -463
  54. package/dist/theme/default/index.mjs.map +1 -1
  55. package/jest.config.ts +1 -1
  56. package/package.json +2 -1
  57. package/postcss.config.ts +1 -0
  58. package/tailwind.config.ts +14 -13
  59. package/tsconfig.json +4 -3
  60. package/variables-processed.json +385 -187
  61. package/.eslintrc.js +0 -63
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/config.ts"],"sourcesContent":["// Copyright © 2024 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * This function returns the base URL of the Ory SDK as set by environment variables `NEXT_PUBLIC_ORY_SDK_URL` or `ORY_SDK_URL`.\n */\nexport function orySdkUrl() {\n let baseUrl\n\n if (process.env.NEXT_PUBLIC_ORY_SDK_URL) {\n baseUrl = process.env.NEXT_PUBLIC_ORY_SDK_URL\n }\n\n if (process.env.ORY_SDK_URL) {\n baseUrl = process.env._ORY_SDK_URL\n }\n\n if (!baseUrl) {\n throw new Error(\n \"You need to set environment variable `NEXT_PUBLIC_ORY_SDK_URL` or if you don't use Next.js `ORY_SDK_URL` to your Ory Network SDK URL.\",\n )\n }\n\n return baseUrl.replace(/\\/$/, \"\")\n}\n\n/**\n * This function returns whether the current environment is a production environment.\n */\nexport function isProduction() {\n return (\n [\"production\", \"prod\"].indexOf(\n process.env.VERCEL_ENV ?? process.env.NODE_ENV ?? \"\",\n ) > -1\n )\n}\n\n/**\n * This function returns the Ory SDK URL. If the environment is not production, it tries to guess the SDK URL based on the environment variables, assuming\n * that Ory APIs are proxied through the same domain as the application.\n *\n * Currently, this is only tested for Vercel deployments.\n *\n * @param options - Options for guessing the SDK URL.\n */\nexport function guessPotentiallyProxiedOrySdkUrl(options?: {\n knownProxiedUrl?: string\n}) {\n if (isProduction()) {\n // In production, we use the production custom domain\n return orySdkUrl()\n }\n\n if (process.env.VERCEL_ENV) {\n // We are in vercel\n\n // The domain name of the generated deployment URL. Example: *.vercel.app. The value does not include the protocol scheme https://.\n //\n // This is only available for preview deployments on Vercel.\n if (!isProduction() && process.env.VERCEL_URL) {\n return `https://${process.env.VERCEL_URL}`.replace(/\\/$/, \"\")\n }\n\n // This is sometimes set by the render server.\n if (process.env.__NEXT_PRIVATE_ORIGIN) {\n return process.env.__NEXT_PRIVATE_ORIGIN.replace(/\\/$/, \"\")\n }\n }\n\n // Unable to figure out the SDK URL. Either because we are not using Vercel or because we are on a local machine.\n // Let's try to use the window location.\n if (typeof window !== \"undefined\") {\n return window.location.origin\n }\n\n if (options?.knownProxiedUrl) {\n return options.knownProxiedUrl\n }\n\n // We tried everything. Let's use the SDK URL.\n const final = orySdkUrl()\n console.warn(\n `Unable to determine a suitable SDK URL for setting up the Next.js integration of Ory Elements. Will proceed using default Ory SDK URL \"${final}\". This is likely not what you want for local development and your authentication and login may not work.`,\n )\n\n return final\n}\n"],"mappings":"AAMO,SAAS,YAAY;AAC1B,MAAI;AAEJ,MAAI,QAAQ,IAAI,yBAAyB;AACvC,cAAU,QAAQ,IAAI;AAAA,EACxB;AAEA,MAAI,QAAQ,IAAI,aAAa;AAC3B,cAAU,QAAQ,IAAI;AAAA,EACxB;AAEA,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,SAAO,QAAQ,QAAQ,OAAO,EAAE;AAClC;AAKO,SAAS,eAAe;AA7B/B;AA8BE,SACE,CAAC,cAAc,MAAM,EAAE;AAAA,KACrB,mBAAQ,IAAI,eAAZ,YAA0B,QAAQ,IAAI,aAAtC,YAAkD;AAAA,EACpD,IAAI;AAER;AAUO,SAAS,iCAAiC,SAE9C;AACD,MAAI,aAAa,GAAG;AAElB,WAAO,UAAU;AAAA,EACnB;AAEA,MAAI,QAAQ,IAAI,YAAY;AAM1B,QAAI,CAAC,aAAa,KAAK,QAAQ,IAAI,YAAY;AAC7C,aAAO,WAAW,QAAQ,IAAI,UAAU,GAAG,QAAQ,OAAO,EAAE;AAAA,IAC9D;AAGA,QAAI,QAAQ,IAAI,uBAAuB;AACrC,aAAO,QAAQ,IAAI,sBAAsB,QAAQ,OAAO,EAAE;AAAA,IAC5D;AAAA,EACF;AAIA,MAAI,OAAO,WAAW,aAAa;AACjC,WAAO,OAAO,SAAS;AAAA,EACzB;AAEA,MAAI,mCAAS,iBAAiB;AAC5B,WAAO,QAAQ;AAAA,EACjB;AAGA,QAAM,QAAQ,UAAU;AACxB,UAAQ;AAAA,IACN,0IAA0I,KAAK;AAAA,EACjJ;AAEA,SAAO;AACT;","names":[]}
@@ -1,5 +1,7 @@
1
1
  import { ConfigurationParameters, FrontendApi } from '@ory/client-fetch';
2
2
 
3
- declare function frontendClient(sdkUrl: string, opts?: Partial<ConfigurationParameters>): FrontendApi;
3
+ declare function frontendClient({ forceBaseUrl, ...opts }?: Partial<ConfigurationParameters & {
4
+ forceBaseUrl?: string;
5
+ }>): FrontendApi;
4
6
 
5
7
  export { frontendClient };
@@ -1,5 +1,7 @@
1
1
  import { ConfigurationParameters, FrontendApi } from '@ory/client-fetch';
2
2
 
3
- declare function frontendClient(sdkUrl: string, opts?: Partial<ConfigurationParameters>): FrontendApi;
3
+ declare function frontendClient({ forceBaseUrl, ...opts }?: Partial<ConfigurationParameters & {
4
+ forceBaseUrl?: string;
5
+ }>): FrontendApi;
4
6
 
5
7
  export { frontendClient };
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ "use client";
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -22,10 +23,21 @@ __export(frontendClient_exports, {
22
23
  });
23
24
  module.exports = __toCommonJS(frontendClient_exports);
24
25
  var import_client_fetch = require("@ory/client-fetch");
25
- function frontendClient(sdkUrl, opts = {}) {
26
+ var import_config = require("./config");
27
+ function frontendClient({
28
+ forceBaseUrl,
29
+ ...opts
30
+ } = {
31
+ credentials: "include"
32
+ }) {
33
+ var _a;
34
+ const basePath = forceBaseUrl != null ? forceBaseUrl : (0, import_config.guessPotentiallyProxiedOrySdkUrl)({
35
+ knownProxiedUrl: window.location.origin
36
+ });
26
37
  const config = new import_client_fetch.Configuration({
27
38
  ...opts,
28
- basePath: sdkUrl,
39
+ basePath: basePath == null ? void 0 : basePath.replace(/\/$/, ""),
40
+ credentials: (_a = opts.credentials) != null ? _a : "include",
29
41
  headers: {
30
42
  Accept: "application/json",
31
43
  ...opts.headers
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/client/frontendClient.ts"],"sourcesContent":["// Copyright © 2024 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n Configuration,\n ConfigurationParameters,\n FrontendApi,\n} from \"@ory/client-fetch\"\n\nexport function frontendClient(\n sdkUrl: string,\n opts: Partial<ConfigurationParameters> = {},\n) {\n const config = new Configuration({\n ...opts,\n basePath: sdkUrl,\n headers: {\n Accept: \"application/json\",\n ...opts.headers,\n },\n })\n return new FrontendApi(config)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAIO;AAEA,SAAS,eACd,QACA,OAAyC,CAAC,GAC1C;AACA,QAAM,SAAS,IAAI,kCAAc;AAAA,IAC/B,GAAG;AAAA,IACH,UAAU;AAAA,IACV,SAAS;AAAA,MACP,QAAQ;AAAA,MACR,GAAG,KAAK;AAAA,IACV;AAAA,EACF,CAAC;AACD,SAAO,IAAI,gCAAY,MAAM;AAC/B;","names":[]}
1
+ {"version":3,"sources":["../../src/client/frontendClient.ts"],"sourcesContent":["// Copyright © 2024 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\"use client\"\nimport {\n Configuration,\n ConfigurationParameters,\n FrontendApi,\n} from \"@ory/client-fetch\"\nimport { guessPotentiallyProxiedOrySdkUrl } from \"./config\"\n\nexport function frontendClient(\n {\n forceBaseUrl,\n ...opts\n }: Partial<ConfigurationParameters & { forceBaseUrl?: string }> = {\n credentials: \"include\",\n },\n) {\n const basePath =\n forceBaseUrl ??\n guessPotentiallyProxiedOrySdkUrl({\n knownProxiedUrl: window.location.origin,\n })\n\n const config = new Configuration({\n ...opts,\n basePath: basePath?.replace(/\\/$/, \"\"),\n credentials: opts.credentials ?? \"include\",\n headers: {\n Accept: \"application/json\",\n ...opts.headers,\n },\n })\n return new FrontendApi(config)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAIO;AACP,oBAAiD;AAE1C,SAAS,eACd;AAAA,EACE;AAAA,EACA,GAAG;AACL,IAAkE;AAAA,EAChE,aAAa;AACf,GACA;AAjBF;AAkBE,QAAM,WACJ,0CACA,gDAAiC;AAAA,IAC/B,iBAAiB,OAAO,SAAS;AAAA,EACnC,CAAC;AAEH,QAAM,SAAS,IAAI,kCAAc;AAAA,IAC/B,GAAG;AAAA,IACH,UAAU,qCAAU,QAAQ,OAAO;AAAA,IACnC,cAAa,UAAK,gBAAL,YAAoB;AAAA,IACjC,SAAS;AAAA,MACP,QAAQ;AAAA,MACR,GAAG,KAAK;AAAA,IACV;AAAA,EACF,CAAC;AACD,SAAO,IAAI,gCAAY,MAAM;AAC/B;","names":[]}
@@ -1,11 +1,23 @@
1
+ "use client";
1
2
  import {
2
3
  Configuration,
3
4
  FrontendApi
4
5
  } from "@ory/client-fetch";
5
- function frontendClient(sdkUrl, opts = {}) {
6
+ import { guessPotentiallyProxiedOrySdkUrl } from "./config";
7
+ function frontendClient({
8
+ forceBaseUrl,
9
+ ...opts
10
+ } = {
11
+ credentials: "include"
12
+ }) {
13
+ var _a;
14
+ const basePath = forceBaseUrl != null ? forceBaseUrl : guessPotentiallyProxiedOrySdkUrl({
15
+ knownProxiedUrl: window.location.origin
16
+ });
6
17
  const config = new Configuration({
7
18
  ...opts,
8
- basePath: sdkUrl,
19
+ basePath: basePath == null ? void 0 : basePath.replace(/\/$/, ""),
20
+ credentials: (_a = opts.credentials) != null ? _a : "include",
9
21
  headers: {
10
22
  Accept: "application/json",
11
23
  ...opts.headers
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/client/frontendClient.ts"],"sourcesContent":["// Copyright © 2024 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n Configuration,\n ConfigurationParameters,\n FrontendApi,\n} from \"@ory/client-fetch\"\n\nexport function frontendClient(\n sdkUrl: string,\n opts: Partial<ConfigurationParameters> = {},\n) {\n const config = new Configuration({\n ...opts,\n basePath: sdkUrl,\n headers: {\n Accept: \"application/json\",\n ...opts.headers,\n },\n })\n return new FrontendApi(config)\n}\n"],"mappings":"AAGA;AAAA,EACE;AAAA,EAEA;AAAA,OACK;AAEA,SAAS,eACd,QACA,OAAyC,CAAC,GAC1C;AACA,QAAM,SAAS,IAAI,cAAc;AAAA,IAC/B,GAAG;AAAA,IACH,UAAU;AAAA,IACV,SAAS;AAAA,MACP,QAAQ;AAAA,MACR,GAAG,KAAK;AAAA,IACV;AAAA,EACF,CAAC;AACD,SAAO,IAAI,YAAY,MAAM;AAC/B;","names":[]}
1
+ {"version":3,"sources":["../../src/client/frontendClient.ts"],"sourcesContent":["// Copyright © 2024 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\"use client\"\nimport {\n Configuration,\n ConfigurationParameters,\n FrontendApi,\n} from \"@ory/client-fetch\"\nimport { guessPotentiallyProxiedOrySdkUrl } from \"./config\"\n\nexport function frontendClient(\n {\n forceBaseUrl,\n ...opts\n }: Partial<ConfigurationParameters & { forceBaseUrl?: string }> = {\n credentials: \"include\",\n },\n) {\n const basePath =\n forceBaseUrl ??\n guessPotentiallyProxiedOrySdkUrl({\n knownProxiedUrl: window.location.origin,\n })\n\n const config = new Configuration({\n ...opts,\n basePath: basePath?.replace(/\\/$/, \"\"),\n credentials: opts.credentials ?? \"include\",\n headers: {\n Accept: \"application/json\",\n ...opts.headers,\n },\n })\n return new FrontendApi(config)\n}\n"],"mappings":";AAGA;AAAA,EACE;AAAA,EAEA;AAAA,OACK;AACP,SAAS,wCAAwC;AAE1C,SAAS,eACd;AAAA,EACE;AAAA,EACA,GAAG;AACL,IAAkE;AAAA,EAChE,aAAa;AACf,GACA;AAjBF;AAkBE,QAAM,WACJ,sCACA,iCAAiC;AAAA,IAC/B,iBAAiB,OAAO,SAAS;AAAA,EACnC,CAAC;AAEH,QAAM,SAAS,IAAI,cAAc;AAAA,IAC/B,GAAG;AAAA,IACH,UAAU,qCAAU,QAAQ,OAAO;AAAA,IACnC,cAAa,UAAK,gBAAL,YAAoB;AAAA,IACjC,SAAS;AAAA,MACP,QAAQ;AAAA,MACR,GAAG,KAAK;AAAA,IACV;AAAA,EACF,CAAC;AACD,SAAO,IAAI,YAAY,MAAM;AAC/B;","names":[]}
@@ -1,3 +1,5 @@
1
+ export { SessionContextData, SessionProvider, SessionProviderProps } from './session-provider.mjs';
1
2
  export { useSession } from './useSession.mjs';
2
- import 'zustand';
3
+ import 'react/jsx-runtime';
4
+ import 'react';
3
5
  import '@ory/client-fetch';
@@ -1,3 +1,5 @@
1
+ export { SessionContextData, SessionProvider, SessionProviderProps } from './session-provider.js';
1
2
  export { useSession } from './useSession.js';
2
- import 'zustand';
3
+ import 'react/jsx-runtime';
4
+ import 'react';
3
5
  import '@ory/client-fetch';
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ "use client";
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -18,12 +19,15 @@ var __copyProps = (to, from, except, desc) => {
18
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
20
  var client_exports = {};
20
21
  __export(client_exports, {
22
+ SessionProvider: () => import_session_provider.SessionProvider,
21
23
  useSession: () => import_useSession.useSession
22
24
  });
23
25
  module.exports = __toCommonJS(client_exports);
26
+ var import_session_provider = require("./session-provider");
24
27
  var import_useSession = require("./useSession");
25
28
  // Annotate the CommonJS export names for ESM import in node:
26
29
  0 && (module.exports = {
30
+ SessionProvider,
27
31
  useSession
28
32
  });
29
33
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/client/index.ts"],"sourcesContent":["// Copyright © 2024 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\nexport { useSession } from \"./useSession\"\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAA2B;","names":[]}
1
+ {"version":3,"sources":["../../src/client/index.ts"],"sourcesContent":["\"use client\"\n// Copyright © 2024 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\nexport {\n SessionProvider,\n type SessionContextData,\n type SessionProviderProps,\n} from \"./session-provider\"\nexport { useSession } from \"./useSession\"\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,8BAIO;AACP,wBAA2B;","names":[]}
@@ -1,5 +1,10 @@
1
+ "use client";
2
+ import {
3
+ SessionProvider
4
+ } from "./session-provider";
1
5
  import { useSession } from "./useSession";
2
6
  export {
7
+ SessionProvider,
3
8
  useSession
4
9
  };
5
10
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/client/index.ts"],"sourcesContent":["// Copyright © 2024 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\nexport { useSession } from \"./useSession\"\n"],"mappings":"AAGA,SAAS,kBAAkB;","names":[]}
1
+ {"version":3,"sources":["../../src/client/index.ts"],"sourcesContent":["\"use client\"\n// Copyright © 2024 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\nexport {\n SessionProvider,\n type SessionContextData,\n type SessionProviderProps,\n} from \"./session-provider\"\nexport { useSession } from \"./useSession\"\n"],"mappings":";AAIA;AAAA,EACE;AAAA,OAGK;AACP,SAAS,kBAAkB;","names":[]}
@@ -0,0 +1,62 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
3
+ import { Session } from '@ory/client-fetch';
4
+
5
+ type SessionContextData = {
6
+ /**
7
+ * Whether the session is currently being loaded
8
+ */
9
+ isLoading: boolean;
10
+ /**
11
+ * Whether the session is being loaded for the first time
12
+ * Never true, if a session was passed to the provider
13
+ */
14
+ initialized: boolean;
15
+ /**
16
+ * The current session or null if the user is not authenticated or an error occurred,
17
+ * when fetching the session
18
+ */
19
+ session: Session | null;
20
+ /**
21
+ * The error that occurred when fetching the session if any
22
+ */
23
+ error: Error | undefined;
24
+ /**
25
+ * Refetches the session
26
+ */
27
+ refetch: () => Promise<void>;
28
+ };
29
+ declare const SessionContext: react.Context<SessionContextData>;
30
+ type SessionProviderProps = {
31
+ session?: Session | null;
32
+ baseUrl?: string;
33
+ } & React.PropsWithChildren;
34
+ /**
35
+ * A provider that fetches the session from the Ory Network and provides it to the children.
36
+ *
37
+ * To use this provider, wrap your application in it:
38
+ *
39
+ * ```tsx
40
+ * import { SessionProvider } from "@ory/elements-react"
41
+ *
42
+ * export default function App() {
43
+ * return (
44
+ * <SessionProvider>
45
+ * <MyApp />
46
+ * </SessionProvider>
47
+ * )
48
+ * }
49
+ * ```
50
+ *
51
+ * If you have a session from the server, you can pass it to the provider:
52
+ *
53
+ * ```tsx
54
+ * <SessionProvider session={serverSession}>
55
+ * ```
56
+ *
57
+ * @see {@link useSession}
58
+ * @param props - The provider props
59
+ */
60
+ declare function SessionProvider({ session: initialSession, children, baseUrl, }: SessionProviderProps): react_jsx_runtime.JSX.Element;
61
+
62
+ export { SessionContext, type SessionContextData, SessionProvider, type SessionProviderProps };
@@ -0,0 +1,62 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
3
+ import { Session } from '@ory/client-fetch';
4
+
5
+ type SessionContextData = {
6
+ /**
7
+ * Whether the session is currently being loaded
8
+ */
9
+ isLoading: boolean;
10
+ /**
11
+ * Whether the session is being loaded for the first time
12
+ * Never true, if a session was passed to the provider
13
+ */
14
+ initialized: boolean;
15
+ /**
16
+ * The current session or null if the user is not authenticated or an error occurred,
17
+ * when fetching the session
18
+ */
19
+ session: Session | null;
20
+ /**
21
+ * The error that occurred when fetching the session if any
22
+ */
23
+ error: Error | undefined;
24
+ /**
25
+ * Refetches the session
26
+ */
27
+ refetch: () => Promise<void>;
28
+ };
29
+ declare const SessionContext: react.Context<SessionContextData>;
30
+ type SessionProviderProps = {
31
+ session?: Session | null;
32
+ baseUrl?: string;
33
+ } & React.PropsWithChildren;
34
+ /**
35
+ * A provider that fetches the session from the Ory Network and provides it to the children.
36
+ *
37
+ * To use this provider, wrap your application in it:
38
+ *
39
+ * ```tsx
40
+ * import { SessionProvider } from "@ory/elements-react"
41
+ *
42
+ * export default function App() {
43
+ * return (
44
+ * <SessionProvider>
45
+ * <MyApp />
46
+ * </SessionProvider>
47
+ * )
48
+ * }
49
+ * ```
50
+ *
51
+ * If you have a session from the server, you can pass it to the provider:
52
+ *
53
+ * ```tsx
54
+ * <SessionProvider session={serverSession}>
55
+ * ```
56
+ *
57
+ * @see {@link useSession}
58
+ * @param props - The provider props
59
+ */
60
+ declare function SessionProvider({ session: initialSession, children, baseUrl, }: SessionProviderProps): react_jsx_runtime.JSX.Element;
61
+
62
+ export { SessionContext, type SessionContextData, SessionProvider, type SessionProviderProps };
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var session_provider_exports = {};
21
+ __export(session_provider_exports, {
22
+ SessionContext: () => SessionContext,
23
+ SessionProvider: () => SessionProvider
24
+ });
25
+ module.exports = __toCommonJS(session_provider_exports);
26
+ var import_jsx_runtime = require("react/jsx-runtime");
27
+ var import_react = require("react");
28
+ var import_frontendClient = require("./frontendClient");
29
+ const SessionContext = (0, import_react.createContext)({
30
+ session: null,
31
+ isLoading: false,
32
+ initialized: false,
33
+ error: void 0,
34
+ refetch: async () => {
35
+ }
36
+ });
37
+ function SessionProvider({
38
+ session: initialSession,
39
+ children,
40
+ baseUrl
41
+ }) {
42
+ const initialized = (0, import_react.useRef)(!!initialSession);
43
+ const [isLoading, setLoading] = (0, import_react.useState)(false);
44
+ const [sessionState, setSessionState] = (0, import_react.useState)(
45
+ () => {
46
+ if (initialSession) {
47
+ return {
48
+ session: initialSession,
49
+ state: initialSession.active ? "authenticated" : "unauthenticated"
50
+ };
51
+ }
52
+ return void 0;
53
+ }
54
+ );
55
+ const fetchSession = (0, import_react.useCallback)(async () => {
56
+ try {
57
+ setLoading(true);
58
+ const session = await (0, import_frontendClient.frontendClient)({
59
+ forceBaseUrl: baseUrl
60
+ }).toSession();
61
+ setSessionState({
62
+ session,
63
+ state: session.active ? "authenticated" : "unauthenticated"
64
+ });
65
+ } catch (error) {
66
+ setSessionState({ state: "error", error });
67
+ } finally {
68
+ setLoading(false);
69
+ }
70
+ }, [baseUrl]);
71
+ (0, import_react.useEffect)(() => {
72
+ if (!initialized.current) {
73
+ initialized.current = true;
74
+ void fetchSession();
75
+ }
76
+ }, [fetchSession]);
77
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
78
+ SessionContext.Provider,
79
+ {
80
+ value: {
81
+ error: (sessionState == null ? void 0 : sessionState.state) === "error" ? sessionState.error : void 0,
82
+ session: (sessionState == null ? void 0 : sessionState.state) === "authenticated" ? sessionState.session : null,
83
+ isLoading,
84
+ initialized: initialized.current,
85
+ refetch: fetchSession
86
+ },
87
+ children
88
+ }
89
+ );
90
+ }
91
+ // Annotate the CommonJS export names for ESM import in node:
92
+ 0 && (module.exports = {
93
+ SessionContext,
94
+ SessionProvider
95
+ });
96
+ //# sourceMappingURL=session-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/session-provider.tsx"],"sourcesContent":["// Copyright © 2024 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\n\"use client\"\nimport { Session } from \"@ory/client-fetch\"\nimport { createContext, useCallback, useEffect, useRef, useState } from \"react\"\nimport { frontendClient } from \"./frontendClient\"\n\ntype SessionState =\n | {\n session: Session\n state: \"authenticated\"\n }\n | {\n state: \"unauthenticated\"\n }\n | {\n state: \"error\"\n error: Error\n }\n\nexport type SessionContextData = {\n /**\n * Whether the session is currently being loaded\n */\n isLoading: boolean\n /**\n * Whether the session is being loaded for the first time\n * Never true, if a session was passed to the provider\n */\n initialized: boolean\n /**\n * The current session or null if the user is not authenticated or an error occurred,\n * when fetching the session\n */\n session: Session | null\n /**\n * The error that occurred when fetching the session if any\n */\n error: Error | undefined\n /**\n * Refetches the session\n */\n refetch: () => Promise<void>\n}\n\nexport const SessionContext = createContext<SessionContextData>({\n session: null,\n isLoading: false,\n initialized: false,\n error: undefined,\n refetch: async () => {},\n})\n\nexport type SessionProviderProps = {\n session?: Session | null\n baseUrl?: string\n} & React.PropsWithChildren\n\n/**\n * A provider that fetches the session from the Ory Network and provides it to the children.\n *\n * To use this provider, wrap your application in it:\n *\n * ```tsx\n * import { SessionProvider } from \"@ory/elements-react\"\n *\n * export default function App() {\n * return (\n * <SessionProvider>\n * <MyApp />\n * </SessionProvider>\n * )\n * }\n * ```\n *\n * If you have a session from the server, you can pass it to the provider:\n *\n * ```tsx\n * <SessionProvider session={serverSession}>\n * ```\n *\n * @see {@link useSession}\n * @param props - The provider props\n */\nexport function SessionProvider({\n session: initialSession,\n children,\n baseUrl,\n}: SessionProviderProps) {\n const initialized = useRef(!!initialSession)\n const [isLoading, setLoading] = useState(false)\n const [sessionState, setSessionState] = useState<SessionState | undefined>(\n () => {\n if (initialSession) {\n return {\n session: initialSession,\n state: initialSession.active ? \"authenticated\" : \"unauthenticated\",\n }\n }\n\n return undefined\n },\n )\n\n const fetchSession = useCallback(async () => {\n try {\n setLoading(true)\n const session = await frontendClient({\n forceBaseUrl: baseUrl,\n }).toSession()\n\n setSessionState({\n session,\n state: session.active ? \"authenticated\" : \"unauthenticated\",\n })\n } catch (error) {\n setSessionState({ state: \"error\", error: error as Error })\n } finally {\n setLoading(false)\n }\n }, [baseUrl])\n\n useEffect(() => {\n if (!initialized.current) {\n initialized.current = true\n void fetchSession()\n }\n }, [fetchSession])\n\n return (\n <SessionContext.Provider\n value={{\n error: sessionState?.state === \"error\" ? sessionState.error : undefined,\n session:\n sessionState?.state === \"authenticated\" ? sessionState.session : null,\n isLoading,\n initialized: initialized.current,\n refetch: fetchSession,\n }}\n >\n {children}\n </SessionContext.Provider>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmII;AA9HJ,mBAAwE;AACxE,4BAA+B;AAwCxB,MAAM,qBAAiB,4BAAkC;AAAA,EAC9D,SAAS;AAAA,EACT,WAAW;AAAA,EACX,aAAa;AAAA,EACb,OAAO;AAAA,EACP,SAAS,YAAY;AAAA,EAAC;AACxB,CAAC;AAiCM,SAAS,gBAAgB;AAAA,EAC9B,SAAS;AAAA,EACT;AAAA,EACA;AACF,GAAyB;AACvB,QAAM,kBAAc,qBAAO,CAAC,CAAC,cAAc;AAC3C,QAAM,CAAC,WAAW,UAAU,QAAI,uBAAS,KAAK;AAC9C,QAAM,CAAC,cAAc,eAAe,QAAI;AAAA,IACtC,MAAM;AACJ,UAAI,gBAAgB;AAClB,eAAO;AAAA,UACL,SAAS;AAAA,UACT,OAAO,eAAe,SAAS,kBAAkB;AAAA,QACnD;AAAA,MACF;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AAEA,QAAM,mBAAe,0BAAY,YAAY;AAC3C,QAAI;AACF,iBAAW,IAAI;AACf,YAAM,UAAU,UAAM,sCAAe;AAAA,QACnC,cAAc;AAAA,MAChB,CAAC,EAAE,UAAU;AAEb,sBAAgB;AAAA,QACd;AAAA,QACA,OAAO,QAAQ,SAAS,kBAAkB;AAAA,MAC5C,CAAC;AAAA,IACH,SAAS,OAAO;AACd,sBAAgB,EAAE,OAAO,SAAS,MAAsB,CAAC;AAAA,IAC3D,UAAE;AACA,iBAAW,KAAK;AAAA,IAClB;AAAA,EACF,GAAG,CAAC,OAAO,CAAC;AAEZ,8BAAU,MAAM;AACd,QAAI,CAAC,YAAY,SAAS;AACxB,kBAAY,UAAU;AACtB,WAAK,aAAa;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,YAAY,CAAC;AAEjB,SACE;AAAA,IAAC,eAAe;AAAA,IAAf;AAAA,MACC,OAAO;AAAA,QACL,QAAO,6CAAc,WAAU,UAAU,aAAa,QAAQ;AAAA,QAC9D,UACE,6CAAc,WAAU,kBAAkB,aAAa,UAAU;AAAA,QACnE;AAAA,QACA,aAAa,YAAY;AAAA,QACzB,SAAS;AAAA,MACX;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;","names":[]}
@@ -0,0 +1,71 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { createContext, useCallback, useEffect, useRef, useState } from "react";
4
+ import { frontendClient } from "./frontendClient";
5
+ const SessionContext = createContext({
6
+ session: null,
7
+ isLoading: false,
8
+ initialized: false,
9
+ error: void 0,
10
+ refetch: async () => {
11
+ }
12
+ });
13
+ function SessionProvider({
14
+ session: initialSession,
15
+ children,
16
+ baseUrl
17
+ }) {
18
+ const initialized = useRef(!!initialSession);
19
+ const [isLoading, setLoading] = useState(false);
20
+ const [sessionState, setSessionState] = useState(
21
+ () => {
22
+ if (initialSession) {
23
+ return {
24
+ session: initialSession,
25
+ state: initialSession.active ? "authenticated" : "unauthenticated"
26
+ };
27
+ }
28
+ return void 0;
29
+ }
30
+ );
31
+ const fetchSession = useCallback(async () => {
32
+ try {
33
+ setLoading(true);
34
+ const session = await frontendClient({
35
+ forceBaseUrl: baseUrl
36
+ }).toSession();
37
+ setSessionState({
38
+ session,
39
+ state: session.active ? "authenticated" : "unauthenticated"
40
+ });
41
+ } catch (error) {
42
+ setSessionState({ state: "error", error });
43
+ } finally {
44
+ setLoading(false);
45
+ }
46
+ }, [baseUrl]);
47
+ useEffect(() => {
48
+ if (!initialized.current) {
49
+ initialized.current = true;
50
+ void fetchSession();
51
+ }
52
+ }, [fetchSession]);
53
+ return /* @__PURE__ */ jsx(
54
+ SessionContext.Provider,
55
+ {
56
+ value: {
57
+ error: (sessionState == null ? void 0 : sessionState.state) === "error" ? sessionState.error : void 0,
58
+ session: (sessionState == null ? void 0 : sessionState.state) === "authenticated" ? sessionState.session : null,
59
+ isLoading,
60
+ initialized: initialized.current,
61
+ refetch: fetchSession
62
+ },
63
+ children
64
+ }
65
+ );
66
+ }
67
+ export {
68
+ SessionContext,
69
+ SessionProvider
70
+ };
71
+ //# sourceMappingURL=session-provider.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/session-provider.tsx"],"sourcesContent":["// Copyright © 2024 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\n\"use client\"\nimport { Session } from \"@ory/client-fetch\"\nimport { createContext, useCallback, useEffect, useRef, useState } from \"react\"\nimport { frontendClient } from \"./frontendClient\"\n\ntype SessionState =\n | {\n session: Session\n state: \"authenticated\"\n }\n | {\n state: \"unauthenticated\"\n }\n | {\n state: \"error\"\n error: Error\n }\n\nexport type SessionContextData = {\n /**\n * Whether the session is currently being loaded\n */\n isLoading: boolean\n /**\n * Whether the session is being loaded for the first time\n * Never true, if a session was passed to the provider\n */\n initialized: boolean\n /**\n * The current session or null if the user is not authenticated or an error occurred,\n * when fetching the session\n */\n session: Session | null\n /**\n * The error that occurred when fetching the session if any\n */\n error: Error | undefined\n /**\n * Refetches the session\n */\n refetch: () => Promise<void>\n}\n\nexport const SessionContext = createContext<SessionContextData>({\n session: null,\n isLoading: false,\n initialized: false,\n error: undefined,\n refetch: async () => {},\n})\n\nexport type SessionProviderProps = {\n session?: Session | null\n baseUrl?: string\n} & React.PropsWithChildren\n\n/**\n * A provider that fetches the session from the Ory Network and provides it to the children.\n *\n * To use this provider, wrap your application in it:\n *\n * ```tsx\n * import { SessionProvider } from \"@ory/elements-react\"\n *\n * export default function App() {\n * return (\n * <SessionProvider>\n * <MyApp />\n * </SessionProvider>\n * )\n * }\n * ```\n *\n * If you have a session from the server, you can pass it to the provider:\n *\n * ```tsx\n * <SessionProvider session={serverSession}>\n * ```\n *\n * @see {@link useSession}\n * @param props - The provider props\n */\nexport function SessionProvider({\n session: initialSession,\n children,\n baseUrl,\n}: SessionProviderProps) {\n const initialized = useRef(!!initialSession)\n const [isLoading, setLoading] = useState(false)\n const [sessionState, setSessionState] = useState<SessionState | undefined>(\n () => {\n if (initialSession) {\n return {\n session: initialSession,\n state: initialSession.active ? \"authenticated\" : \"unauthenticated\",\n }\n }\n\n return undefined\n },\n )\n\n const fetchSession = useCallback(async () => {\n try {\n setLoading(true)\n const session = await frontendClient({\n forceBaseUrl: baseUrl,\n }).toSession()\n\n setSessionState({\n session,\n state: session.active ? \"authenticated\" : \"unauthenticated\",\n })\n } catch (error) {\n setSessionState({ state: \"error\", error: error as Error })\n } finally {\n setLoading(false)\n }\n }, [baseUrl])\n\n useEffect(() => {\n if (!initialized.current) {\n initialized.current = true\n void fetchSession()\n }\n }, [fetchSession])\n\n return (\n <SessionContext.Provider\n value={{\n error: sessionState?.state === \"error\" ? sessionState.error : undefined,\n session:\n sessionState?.state === \"authenticated\" ? sessionState.session : null,\n isLoading,\n initialized: initialized.current,\n refetch: fetchSession,\n }}\n >\n {children}\n </SessionContext.Provider>\n )\n}\n"],"mappings":";AAmII;AA9HJ,SAAS,eAAe,aAAa,WAAW,QAAQ,gBAAgB;AACxE,SAAS,sBAAsB;AAwCxB,MAAM,iBAAiB,cAAkC;AAAA,EAC9D,SAAS;AAAA,EACT,WAAW;AAAA,EACX,aAAa;AAAA,EACb,OAAO;AAAA,EACP,SAAS,YAAY;AAAA,EAAC;AACxB,CAAC;AAiCM,SAAS,gBAAgB;AAAA,EAC9B,SAAS;AAAA,EACT;AAAA,EACA;AACF,GAAyB;AACvB,QAAM,cAAc,OAAO,CAAC,CAAC,cAAc;AAC3C,QAAM,CAAC,WAAW,UAAU,IAAI,SAAS,KAAK;AAC9C,QAAM,CAAC,cAAc,eAAe,IAAI;AAAA,IACtC,MAAM;AACJ,UAAI,gBAAgB;AAClB,eAAO;AAAA,UACL,SAAS;AAAA,UACT,OAAO,eAAe,SAAS,kBAAkB;AAAA,QACnD;AAAA,MACF;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AAEA,QAAM,eAAe,YAAY,YAAY;AAC3C,QAAI;AACF,iBAAW,IAAI;AACf,YAAM,UAAU,MAAM,eAAe;AAAA,QACnC,cAAc;AAAA,MAChB,CAAC,EAAE,UAAU;AAEb,sBAAgB;AAAA,QACd;AAAA,QACA,OAAO,QAAQ,SAAS,kBAAkB;AAAA,MAC5C,CAAC;AAAA,IACH,SAAS,OAAO;AACd,sBAAgB,EAAE,OAAO,SAAS,MAAsB,CAAC;AAAA,IAC3D,UAAE;AACA,iBAAW,KAAK;AAAA,IAClB;AAAA,EACF,GAAG,CAAC,OAAO,CAAC;AAEZ,YAAU,MAAM;AACd,QAAI,CAAC,YAAY,SAAS;AACxB,kBAAY,UAAU;AACtB,WAAK,aAAa;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,YAAY,CAAC;AAEjB,SACE;AAAA,IAAC,eAAe;AAAA,IAAf;AAAA,MACC,OAAO;AAAA,QACL,QAAO,6CAAc,WAAU,UAAU,aAAa,QAAQ;AAAA,QAC9D,UACE,6CAAc,WAAU,kBAAkB,aAAa,UAAU;AAAA,QACnE;AAAA,QACA,aAAa,YAAY;AAAA,QACzB,SAAS;AAAA,MACX;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;","names":[]}
@@ -1,41 +1,32 @@
1
- import * as zustand from 'zustand';
2
- import { Session } from '@ory/client-fetch';
1
+ import { SessionContextData } from './session-provider.mjs';
2
+ import 'react/jsx-runtime';
3
+ import 'react';
4
+ import '@ory/client-fetch';
3
5
 
4
- type SessionStore = {
5
- setIsLoading: (loading: boolean) => void;
6
- setSession: (session: Session) => void;
7
- isLoading: boolean;
8
- session: Session | undefined;
9
- error: string | undefined;
10
- setError: (error: string | undefined) => void;
11
- };
12
- declare const sessionStore: zustand.UseBoundStore<Omit<zustand.StoreApi<SessionStore>, "subscribe"> & {
13
- subscribe: {
14
- (listener: (selectedState: SessionStore, previousSelectedState: SessionStore) => void): () => void;
15
- <U>(selector: (state: SessionStore) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
16
- equalityFn?: ((a: U, b: U) => boolean) | undefined;
17
- fireImmediately?: boolean | undefined;
18
- } | undefined): () => void;
19
- };
20
- }>;
21
6
  /**
22
7
  * A hook to get the current session from the Ory Network.
23
8
  *
24
9
  * Usage:
25
10
  * ```ts
26
- * const { session, error, isLoading } = useSession()
11
+ * const session = useSession()
12
+ *
13
+ * if (session.state == "loading") {
14
+ * return <div>Loading...</div>
15
+ * }
16
+ *
17
+ * if (session.state == "authenticated") {
18
+ * return <div>Session: {session.session.id}</div>
19
+ * }
27
20
  * ```
28
21
  *
29
- * @returns The current session, error and loading state.
22
+ * :::note
23
+ * This is a client-side hook and must be used within a React component.
24
+ * On the server, you can use the getServerSession function from `@ory/nextjs`
25
+ * and hydrate SessionProvider with the session.
26
+ * :::
27
+ *
28
+ * @returns The current session, and error or loading state.
30
29
  */
31
- declare const useSession: (config?: {
32
- sdk: {
33
- url: string;
34
- };
35
- }) => {
36
- session: Session | undefined;
37
- error: string | undefined;
38
- isLoading: boolean;
39
- };
30
+ declare function useSession(): SessionContextData;
40
31
 
41
- export { sessionStore, useSession };
32
+ export { useSession };
@@ -1,41 +1,32 @@
1
- import * as zustand from 'zustand';
2
- import { Session } from '@ory/client-fetch';
1
+ import { SessionContextData } from './session-provider.js';
2
+ import 'react/jsx-runtime';
3
+ import 'react';
4
+ import '@ory/client-fetch';
3
5
 
4
- type SessionStore = {
5
- setIsLoading: (loading: boolean) => void;
6
- setSession: (session: Session) => void;
7
- isLoading: boolean;
8
- session: Session | undefined;
9
- error: string | undefined;
10
- setError: (error: string | undefined) => void;
11
- };
12
- declare const sessionStore: zustand.UseBoundStore<Omit<zustand.StoreApi<SessionStore>, "subscribe"> & {
13
- subscribe: {
14
- (listener: (selectedState: SessionStore, previousSelectedState: SessionStore) => void): () => void;
15
- <U>(selector: (state: SessionStore) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
16
- equalityFn?: ((a: U, b: U) => boolean) | undefined;
17
- fireImmediately?: boolean | undefined;
18
- } | undefined): () => void;
19
- };
20
- }>;
21
6
  /**
22
7
  * A hook to get the current session from the Ory Network.
23
8
  *
24
9
  * Usage:
25
10
  * ```ts
26
- * const { session, error, isLoading } = useSession()
11
+ * const session = useSession()
12
+ *
13
+ * if (session.state == "loading") {
14
+ * return <div>Loading...</div>
15
+ * }
16
+ *
17
+ * if (session.state == "authenticated") {
18
+ * return <div>Session: {session.session.id}</div>
19
+ * }
27
20
  * ```
28
21
  *
29
- * @returns The current session, error and loading state.
22
+ * :::note
23
+ * This is a client-side hook and must be used within a React component.
24
+ * On the server, you can use the getServerSession function from `@ory/nextjs`
25
+ * and hydrate SessionProvider with the session.
26
+ * :::
27
+ *
28
+ * @returns The current session, and error or loading state.
30
29
  */
31
- declare const useSession: (config?: {
32
- sdk: {
33
- url: string;
34
- };
35
- }) => {
36
- session: Session | undefined;
37
- error: string | undefined;
38
- isLoading: boolean;
39
- };
30
+ declare function useSession(): SessionContextData;
40
31
 
41
- export { sessionStore, useSession };
32
+ export { useSession };