@stytch/nextjs 21.4.3 → 21.5.0

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 (37) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/StytchB2BContext-54aa990c.d.ts +272 -0
  3. package/dist/{StytchB2BContext-a2d58b5b.js → StytchB2BContext-54aa990c.js} +44 -40
  4. package/dist/StytchB2BContext-c5062f9b.d.ts +272 -0
  5. package/dist/{StytchB2BContext-fc9fdcb3.js → StytchB2BContext-c5062f9b.js} +43 -39
  6. package/dist/{StytchSSRProxy-4e34fb34.js → StytchSSRProxy-34c789b5.js} +3 -2
  7. package/dist/{StytchSSRProxy-c9d3bc41.js → StytchSSRProxy-86bc42b3.js} +3 -1
  8. package/dist/adminPortal/index.esm.js +3 -3
  9. package/dist/adminPortal/index.js +3 -3
  10. package/dist/b2b/index.d.ts +19 -23
  11. package/dist/b2b/index.esm.d.ts +19 -23
  12. package/dist/b2b/index.esm.js +19 -24
  13. package/dist/b2b/index.headless.esm.js +1 -1
  14. package/dist/b2b/index.headless.js +1 -1
  15. package/dist/b2b/index.js +18 -23
  16. package/dist/b2b/index.ui.esm.js +1 -1
  17. package/dist/b2b/index.ui.js +1 -1
  18. package/dist/errors-d9d5fbc8.d.ts +5 -0
  19. package/dist/index-b14d4efe.d.ts +1 -1
  20. package/dist/index.d.ts +93 -55
  21. package/dist/index.esm.d.ts +93 -55
  22. package/dist/index.esm.js +55 -66
  23. package/dist/index.headless.esm.js +1 -1
  24. package/dist/index.headless.js +1 -1
  25. package/dist/index.js +54 -65
  26. package/dist/index.ui.esm.js +1 -1
  27. package/dist/index.ui.js +1 -1
  28. package/dist/{useIsomorphicLayoutEffect-2962f7c7.d.ts → useIsomorphicLayoutEffect-1babb81e.d.ts} +3 -3
  29. package/dist/{useIsomorphicLayoutEffect-a2b587d2.d.ts → useIsomorphicLayoutEffect-65746ef3.d.ts} +3 -3
  30. package/package.json +5 -4
  31. package/dist/StytchB2BContext-a2d58b5b.d.ts +0 -177
  32. package/dist/StytchB2BContext-fc9fdcb3.d.ts +0 -177
  33. package/dist/errors-d9d48ed4.d.ts +0 -4
  34. package/dist/{StytchSSRProxy-4e34fb34.d.ts → StytchSSRProxy-34c789b5.d.ts} +0 -0
  35. package/dist/{StytchSSRProxy-c9d3bc41.d.ts → StytchSSRProxy-86bc42b3.d.ts} +0 -0
  36. package/dist/{useIsomorphicLayoutEffect-2962f7c7.js → useIsomorphicLayoutEffect-1babb81e.js} +6 -6
  37. package/dist/{useIsomorphicLayoutEffect-a2b587d2.js → useIsomorphicLayoutEffect-65746ef3.js} +6 -6
@@ -1,8 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import React from "react";
3
3
  import { Callbacks, StyleConfig, StytchB2BUIConfig, StytchProjectConfigurationInput } from "@stytch/vanilla-js";
4
- // We need to import the StytchB2BUIClient type to give the TSDoc parser a hint as to where it is from
5
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
6
4
  import { IDPConsentScreenManifest } from "@stytch/vanilla-js/b2b";
7
5
  interface StytchB2BProps<TProjectConfiguration extends StytchProjectConfigurationInput = Stytch.DefaultProjectConfiguration> {
8
6
  /**
@@ -76,14 +74,17 @@ type B2BIDPConsentManifestGenerator = (input: {
76
74
  clientName: string;
77
75
  }) => IDPConsentScreenManifest;
78
76
  type B2BIdentityProviderProps = Omit<StytchB2BProps, "config"> & {
77
+ /**
78
+ * Optional {@link B2BIDPConsentManifestGenerator} to customize the consent screen.
79
+ */
79
80
  getIDPConsentManifest?: B2BIDPConsentManifestGenerator;
80
81
  };
81
82
  /**
82
83
  * The Stytch B2B UI component.
83
- * This component can only be used with a {@link StytchB2BUIClient} client constructor
84
- * passed into the {@link StytchB2BProvider}
84
+ * This component can only be used with a Stytch B2B UI Client
85
+ * passed into the StytchB2BProvider.
85
86
  *
86
- * See the {@link https://stytch.com/docs/b2b/sdks/javascript-sdk online reference}
87
+ * See the {@link https://stytch.com/docs/b2b/sdks online reference}
87
88
  *
88
89
  * @example
89
90
  * <StytchB2B
@@ -110,28 +111,27 @@ type B2BIdentityProviderProps = Omit<StytchB2BProps, "config"> & {
110
111
  * onEvent: (event) => console.log(event)
111
112
  * }}
112
113
  * />
113
- * @param props {@link StytchB2BProps}
114
114
  */
115
115
  declare const StytchB2B: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>({ styles, callbacks, config }: StytchB2BProps<TProjectConfiguration>) => React.JSX.Element;
116
116
  /**
117
117
  * The Stytch B2B IDP component.
118
118
  * Parses OAuth Authorization params (client_id, scope, nonce, etc.) out of the page URL.
119
119
  * Requires the user to be logged in.
120
- * This component can only be used with a {@link StytchB2BUIClient} client constructor
121
- * passed into the {@link StytchB2BProvider}
120
+ * This component can only be used with a Stytch B2B UI Client
121
+ * passed into the StytchB2BProvider.
122
122
  *
123
- * See the {@link https://stytch.com/docs/sdks/javascript-sdk online reference}
123
+ * See the {@link https://stytch.com/docs/b2b/sdks online reference}
124
124
  *
125
125
  * @example
126
126
  * const styles = {
127
- * container: {
128
- * backgroundColor: '#e11e1e',
129
- * },
130
- * colors: {
131
- * primary: '#ff00f7',
132
- * secondary: '#5C727D',
133
- * },
134
- * }
127
+ * container: {
128
+ * backgroundColor: '#e11e1e',
129
+ * },
130
+ * colors: {
131
+ * primary: '#ff00f7',
132
+ * secondary: '#5C727D',
133
+ * },
134
+ * }
135
135
  *
136
136
  * <B2BIdentityProvider
137
137
  * styles={styles}
@@ -139,12 +139,8 @@ declare const StytchB2B: <TProjectConfiguration extends Partial<import("@stytch/
139
139
  * onEvent: (event) => console.log(event)
140
140
  * }}
141
141
  * />
142
- *
143
- * @param styles - An optional {@link StyleConfig} to customize the look and feel of the screen.
144
- * @param callbacks - An optional {@link Callbacks} object
145
- * @param getIDPConsentManifest - Optional {@link B2BIDPConsentManifestGenerator} to customize the consent screen.
146
142
  */
147
143
  declare const B2BIdentityProvider: ({ styles, callbacks, getIDPConsentManifest }: B2BIdentityProviderProps) => React.JSX.Element;
148
- export { StytchB2BProvider, useStytchB2BClient, useStytchMemberSession, useStytchMember, useStytchIsAuthorized, useStytchOrganization, withStytchB2BClient, withStytchMemberSession, withStytchMember, withStytchOrganization, withStytchPermissions } from "../StytchB2BContext-a2d58b5b.js";
144
+ export { StytchB2BProvider, useStytchB2BClient, useStytchMemberSession, useStytchMember, useStytchIsAuthorized, useStytchOrganization, withStytchB2BClient, withStytchMemberSession, withStytchMember, withStytchOrganization, withStytchPermissions } from "../StytchB2BContext-54aa990c.js";
149
145
  export { StytchB2B, B2BIdentityProvider };
150
- export type { StytchB2BProviderProps } from "../StytchB2BContext-a2d58b5b.js";
146
+ export type { StytchB2BProviderProps } from "../StytchB2BContext-54aa990c.js";
@@ -1,15 +1,15 @@
1
- import { u as useIsMounted__INTERNAL, a as useStytchB2BClient, i as isUIClient, b as useStytchMember } from '../StytchB2BContext-a2d58b5b.js';
2
- export { S as StytchB2BProvider, a as useStytchB2BClient, d as useStytchIsAuthorized, b as useStytchMember, c as useStytchMemberSession, e as useStytchOrganization, w as withStytchB2BClient, g as withStytchMember, f as withStytchMemberSession, h as withStytchOrganization, j as withStytchPermissions } from '../StytchB2BContext-a2d58b5b.js';
1
+ import { u as useIsMounted__INTERNAL, a as useStytchB2BClient, i as isUIClient, b as useStytchMember } from '../StytchB2BContext-54aa990c.js';
2
+ export { S as StytchB2BProvider, a as useStytchB2BClient, d as useStytchIsAuthorized, b as useStytchMember, c as useStytchMemberSession, e as useStytchOrganization, w as withStytchB2BClient, g as withStytchMember, f as withStytchMemberSession, h as withStytchOrganization, j as withStytchPermissions } from '../StytchB2BContext-54aa990c.js';
3
3
  import React, { useRef } from 'react';
4
- import { i as invariant, a as useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect-2962f7c7.js';
5
- import { a as noHeadlessClientError, n as noProviderError } from '../StytchSSRProxy-4e34fb34.js';
4
+ import { i as invariant, a as useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect-1babb81e.js';
5
+ import { a as noHeadlessClientError, n as noProviderError } from '../StytchSSRProxy-34c789b5.js';
6
6
 
7
7
  /**
8
8
  * The Stytch B2B UI component.
9
- * This component can only be used with a {@link StytchB2BUIClient} client constructor
10
- * passed into the {@link StytchB2BProvider}
9
+ * This component can only be used with a Stytch B2B UI Client
10
+ * passed into the StytchB2BProvider.
11
11
  *
12
- * See the {@link https://stytch.com/docs/b2b/sdks/javascript-sdk online reference}
12
+ * See the {@link https://stytch.com/docs/b2b/sdks online reference}
13
13
  *
14
14
  * @example
15
15
  * <StytchB2B
@@ -36,7 +36,6 @@ import { a as noHeadlessClientError, n as noProviderError } from '../StytchSSRPr
36
36
  * onEvent: (event) => console.log(event)
37
37
  * }}
38
38
  * />
39
- * @param props {@link StytchB2BProps}
40
39
  */
41
40
  const StytchB2B = ({ styles, callbacks, config, }) => {
42
41
  invariant(useIsMounted__INTERNAL(), noProviderError('<StytchB2B />', 'StytchB2BProvider'));
@@ -67,21 +66,21 @@ const StytchB2B = ({ styles, callbacks, config, }) => {
67
66
  * The Stytch B2B IDP component.
68
67
  * Parses OAuth Authorization params (client_id, scope, nonce, etc.) out of the page URL.
69
68
  * Requires the user to be logged in.
70
- * This component can only be used with a {@link StytchB2BUIClient} client constructor
71
- * passed into the {@link StytchB2BProvider}
69
+ * This component can only be used with a Stytch B2B UI Client
70
+ * passed into the StytchB2BProvider.
72
71
  *
73
- * See the {@link https://stytch.com/docs/sdks/javascript-sdk online reference}
72
+ * See the {@link https://stytch.com/docs/b2b/sdks online reference}
74
73
  *
75
74
  * @example
76
75
  * const styles = {
77
- * container: {
78
- * backgroundColor: '#e11e1e',
79
- * },
80
- * colors: {
81
- * primary: '#ff00f7',
82
- * secondary: '#5C727D',
83
- * },
84
- * }
76
+ * container: {
77
+ * backgroundColor: '#e11e1e',
78
+ * },
79
+ * colors: {
80
+ * primary: '#ff00f7',
81
+ * secondary: '#5C727D',
82
+ * },
83
+ * }
85
84
  *
86
85
  * <B2BIdentityProvider
87
86
  * styles={styles}
@@ -89,16 +88,12 @@ const StytchB2B = ({ styles, callbacks, config, }) => {
89
88
  * onEvent: (event) => console.log(event)
90
89
  * }}
91
90
  * />
92
- *
93
- * @param styles - An optional {@link StyleConfig} to customize the look and feel of the screen.
94
- * @param callbacks - An optional {@link Callbacks} object
95
- * @param getIDPConsentManifest - Optional {@link B2BIDPConsentManifestGenerator} to customize the consent screen.
96
91
  */
97
92
  const B2BIdentityProvider = ({ styles, callbacks, getIDPConsentManifest }) => {
98
93
  invariant(useIsMounted__INTERNAL(), noProviderError('<IdentityProvider />'));
99
94
  const stytchClient = useStytchB2BClient();
100
- const containerEl = useRef(null);
101
95
  const { member } = useStytchMember();
96
+ const containerEl = useRef(null);
102
97
  useIsomorphicLayoutEffect(() => {
103
98
  if (!isUIClient(stytchClient)) {
104
99
  throw Error(noHeadlessClientError);
@@ -1,5 +1,5 @@
1
1
  import { StytchB2BHeadlessClient } from '@stytch/vanilla-js/b2b/headless';
2
- import { c as createStytchSSRProxy } from '../StytchSSRProxy-4e34fb34.js';
2
+ import { c as createStytchSSRProxy } from '../StytchSSRProxy-34c789b5.js';
3
3
 
4
4
  /**
5
5
  * Creates a Headless Stytch client object to call the stytch B2B APIs.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var headless = require('@stytch/vanilla-js/b2b/headless');
6
- var StytchSSRProxy = require('../StytchSSRProxy-c9d3bc41.js');
6
+ var StytchSSRProxy = require('../StytchSSRProxy-86bc42b3.js');
7
7
 
8
8
  /**
9
9
  * Creates a Headless Stytch client object to call the stytch B2B APIs.
package/dist/b2b/index.js CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var StytchB2BContext = require('../StytchB2BContext-fc9fdcb3.js');
5
+ var StytchB2BContext = require('../StytchB2BContext-c5062f9b.js');
6
6
  var React = require('react');
7
- var useIsomorphicLayoutEffect = require('../useIsomorphicLayoutEffect-a2b587d2.js');
8
- var StytchSSRProxy = require('../StytchSSRProxy-c9d3bc41.js');
7
+ var useIsomorphicLayoutEffect = require('../useIsomorphicLayoutEffect-65746ef3.js');
8
+ var StytchSSRProxy = require('../StytchSSRProxy-86bc42b3.js');
9
9
 
10
10
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
11
 
@@ -13,10 +13,10 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
13
13
 
14
14
  /**
15
15
  * The Stytch B2B UI component.
16
- * This component can only be used with a {@link StytchB2BUIClient} client constructor
17
- * passed into the {@link StytchB2BProvider}
16
+ * This component can only be used with a Stytch B2B UI Client
17
+ * passed into the StytchB2BProvider.
18
18
  *
19
- * See the {@link https://stytch.com/docs/b2b/sdks/javascript-sdk online reference}
19
+ * See the {@link https://stytch.com/docs/b2b/sdks online reference}
20
20
  *
21
21
  * @example
22
22
  * <StytchB2B
@@ -43,7 +43,6 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
43
43
  * onEvent: (event) => console.log(event)
44
44
  * }}
45
45
  * />
46
- * @param props {@link StytchB2BProps}
47
46
  */
48
47
  const StytchB2B = ({ styles, callbacks, config, }) => {
49
48
  useIsomorphicLayoutEffect.invariant(StytchB2BContext.useIsMounted__INTERNAL(), StytchSSRProxy.noProviderError('<StytchB2B />', 'StytchB2BProvider'));
@@ -74,21 +73,21 @@ const StytchB2B = ({ styles, callbacks, config, }) => {
74
73
  * The Stytch B2B IDP component.
75
74
  * Parses OAuth Authorization params (client_id, scope, nonce, etc.) out of the page URL.
76
75
  * Requires the user to be logged in.
77
- * This component can only be used with a {@link StytchB2BUIClient} client constructor
78
- * passed into the {@link StytchB2BProvider}
76
+ * This component can only be used with a Stytch B2B UI Client
77
+ * passed into the StytchB2BProvider.
79
78
  *
80
- * See the {@link https://stytch.com/docs/sdks/javascript-sdk online reference}
79
+ * See the {@link https://stytch.com/docs/b2b/sdks online reference}
81
80
  *
82
81
  * @example
83
82
  * const styles = {
84
- * container: {
85
- * backgroundColor: '#e11e1e',
86
- * },
87
- * colors: {
88
- * primary: '#ff00f7',
89
- * secondary: '#5C727D',
90
- * },
91
- * }
83
+ * container: {
84
+ * backgroundColor: '#e11e1e',
85
+ * },
86
+ * colors: {
87
+ * primary: '#ff00f7',
88
+ * secondary: '#5C727D',
89
+ * },
90
+ * }
92
91
  *
93
92
  * <B2BIdentityProvider
94
93
  * styles={styles}
@@ -96,16 +95,12 @@ const StytchB2B = ({ styles, callbacks, config, }) => {
96
95
  * onEvent: (event) => console.log(event)
97
96
  * }}
98
97
  * />
99
- *
100
- * @param styles - An optional {@link StyleConfig} to customize the look and feel of the screen.
101
- * @param callbacks - An optional {@link Callbacks} object
102
- * @param getIDPConsentManifest - Optional {@link B2BIDPConsentManifestGenerator} to customize the consent screen.
103
98
  */
104
99
  const B2BIdentityProvider = ({ styles, callbacks, getIDPConsentManifest }) => {
105
100
  useIsomorphicLayoutEffect.invariant(StytchB2BContext.useIsMounted__INTERNAL(), StytchSSRProxy.noProviderError('<IdentityProvider />'));
106
101
  const stytchClient = StytchB2BContext.useStytchB2BClient();
107
- const containerEl = React.useRef(null);
108
102
  const { member } = StytchB2BContext.useStytchMember();
103
+ const containerEl = React.useRef(null);
109
104
  useIsomorphicLayoutEffect.useIsomorphicLayoutEffect(() => {
110
105
  if (!StytchB2BContext.isUIClient(stytchClient)) {
111
106
  throw Error(StytchSSRProxy.noHeadlessClientError);
@@ -1,5 +1,5 @@
1
1
  import { StytchB2BUIClient } from '@stytch/vanilla-js/b2b';
2
- import { c as createStytchSSRProxy } from '../StytchSSRProxy-4e34fb34.js';
2
+ import { c as createStytchSSRProxy } from '../StytchSSRProxy-34c789b5.js';
3
3
 
4
4
  /**
5
5
  * Creates a Stytch UI client object to call the Stytch APIs and render Stytch UI components.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var b2b = require('@stytch/vanilla-js/b2b');
6
- var StytchSSRProxy = require('../StytchSSRProxy-c9d3bc41.js');
6
+ var StytchSSRProxy = require('../StytchSSRProxy-86bc42b3.js');
7
7
 
8
8
  /**
9
9
  * Creates a Stytch UI client object to call the Stytch APIs and render Stytch UI components.
@@ -0,0 +1,5 @@
1
+ declare const noProviderError: (item: string, provider?: string) => string;
2
+ declare const providerMustBeUniqueError = "You cannot render a <StytchProvider> inside another <StytchProvider>.";
3
+ declare const noHeadlessClientError = "Tried to create a Stytch Login UI element using the Stytch Headless SDK.\nYou must use the UI SDK to use UI elements.\nPlease make sure you are using a Stytch UI client, not a Stytch Headless client.";
4
+ declare const cannotInvokeMethodOnServerError: (path: string) => string;
5
+ export { noProviderError, providerMustBeUniqueError, noHeadlessClientError, cannotInvokeMethodOnServerError };
@@ -1,2 +1,2 @@
1
1
  export { createDeepEqual } from "./createDeepEqual-5555f2e1.js";
2
- export { mergeWithStableProps } from "./useIsomorphicLayoutEffect-2962f7c7.js";
2
+ export { mergeWithStableProps } from "./useIsomorphicLayoutEffect-1babb81e.js";
package/dist/index.d.ts CHANGED
@@ -1,37 +1,76 @@
1
1
  /// <reference types="react" />
2
2
  import React from "react";
3
3
  import { ReactNode } from "react";
4
- import { User, Session, StytchUIClient, StytchProjectConfigurationInput, Callbacks, StytchLoginConfig, StyleConfig } from "@stytch/vanilla-js";
4
+ import { Session, StytchProjectConfigurationInput, StytchUIClient, User, Callbacks, StytchLoginConfig, StyleConfig } from "@stytch/vanilla-js";
5
5
  import { StytchHeadlessClient } from "@stytch/vanilla-js/headless";
6
6
  /**
7
- * The Stytch Client object passed in to <StytchProvider /> in your `_app.js`.
7
+ * The Stytch Client object passed in to <StytchProvider /> in your application root.
8
8
  * Either a StytchUIClient or StytchHeadlessClient.
9
9
  */
10
10
  type StytchClient<TProjectConfiguration extends StytchProjectConfigurationInput> = StytchUIClient<TProjectConfiguration> | StytchHeadlessClient<TProjectConfiguration>;
11
- type SWRUser = {
11
+ type SWRUserUninitialized = {
12
+ /**
13
+ * Either the active {@link User} object, or null if the user is not logged in.
14
+ */
12
15
  user: null;
16
+ /**
17
+ * If true, indicates that the value returned is from the application cache and a state refresh is in progress.
18
+ */
13
19
  fromCache: false;
20
+ /**
21
+ * If true, indicates that the SDK has completed initialization.
22
+ */
14
23
  isInitialized: false;
15
- } | {
24
+ };
25
+ type SWRUserInitialized = {
26
+ /**
27
+ * Either the active {@link User} object, or null if the user is not logged in.
28
+ */
16
29
  user: User | null;
30
+ /**
31
+ * If true, indicates that the value returned is from the application cache and a state refresh is in progress.
32
+ */
17
33
  fromCache: boolean;
34
+ /**
35
+ * If true, indicates that the SDK has completed initialization.
36
+ */
18
37
  isInitialized: true;
19
38
  };
20
- type SWRSession = {
39
+ type SWRUser<TAlwaysInitialized extends boolean = boolean> = TAlwaysInitialized extends true ? SWRUserInitialized : SWRUserInitialized | SWRUserUninitialized;
40
+ type SWRSessionUninitialized = {
41
+ /**
42
+ * Either the active {@link Session} object, or null if the user is not logged in.
43
+ */
21
44
  session: null;
45
+ /**
46
+ * If true, indicates that the value returned is from the application cache and a state refresh is in progress.
47
+ */
22
48
  fromCache: false;
49
+ /**
50
+ * If true, indicates that the SDK has completed initialization.
51
+ */
23
52
  isInitialized: false;
24
- } | {
53
+ };
54
+ type SWRSessionInitialized = {
55
+ /**
56
+ * Either the active {@link Session} object, or null if the user is not logged in.
57
+ */
25
58
  session: Session | null;
59
+ /**
60
+ * If true, indicates that the value returned is from the application cache and a state refresh is in progress.
61
+ */
26
62
  fromCache: boolean;
63
+ /**
64
+ * If true, indicates that the SDK has completed initialization.
65
+ */
27
66
  isInitialized: true;
28
67
  };
68
+ type SWRSession<TAlwaysInitialized extends boolean = boolean> = TAlwaysInitialized extends true ? SWRSessionInitialized : SWRSessionInitialized | SWRSessionUninitialized;
29
69
  /**
30
70
  * Returns the active User.
31
71
  * The Stytch SDKs are used for client-side authentication and session management.
32
72
  * Check the isInitialized property to determine if the SDK has completed initialization.
33
- * Check the fromCache property to determine if the session data is from persistent storage.
34
- * See Next's {@link https://nextjs.org/docs/authentication#authenticating-statically-generated-pages documentation} for more.
73
+ * Check the fromCache property to determine if the user data is from persistent storage.
35
74
  * @example
36
75
  * const {user, isInitialized, fromCache} = useStytchUser();
37
76
  * if (!isInitialized) {
@@ -39,13 +78,12 @@ type SWRSession = {
39
78
  * }
40
79
  * return (<h1>Welcome, {user.name.first_name}</h1>);
41
80
  */
42
- declare const useStytchUser: () => SWRUser;
81
+ declare const useStytchUser: <TAssumeHydrated extends boolean = false>() => SWRUser<TAssumeHydrated>;
43
82
  /**
44
- * Returns the user's active Stytch session.
83
+ * Returns the active user's Stytch session.
45
84
  * The Stytch SDKs are used for client-side authentication and session management.
46
85
  * Check the isInitialized property to determine if the SDK has completed initialization.
47
86
  * Check the fromCache property to determine if the session data is from persistent storage.
48
- * See Next's {@link https://nextjs.org/docs/authentication#authenticating-statically-generated-pages documentation} for more.
49
87
  * @example
50
88
  * const {session, isInitialized, fromCache} = useStytchSession();
51
89
  * useEffect(() => {
@@ -57,7 +95,7 @@ declare const useStytchUser: () => SWRUser;
57
95
  * }
58
96
  * }, [session, isInitialized]);
59
97
  */
60
- declare const useStytchSession: () => SWRSession;
98
+ declare const useStytchSession: <TAssumeHydrated extends boolean = false>() => SWRSession<TAssumeHydrated>;
61
99
  /**
62
100
  * Returns the Stytch client stored in the Stytch context.
63
101
  *
@@ -71,12 +109,12 @@ declare const useStytch: <TProjectConfiguration extends Partial<import("@stytch/
71
109
  declare const withStytch: <T extends object, TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>(Component: React.ComponentType<T & {
72
110
  stytch: StytchClient<TProjectConfiguration>;
73
111
  }>) => React.ComponentType<T>;
74
- declare const withStytchUser: <T extends object>(Component: React.ComponentType<T & {
112
+ declare const withStytchUser: <T extends object, TAssumeHydrated extends boolean = false>(Component: React.ComponentType<T & {
75
113
  stytchUser: User | null;
76
114
  stytchUserIsInitialized: boolean;
77
115
  stytchUserIsFromCache: boolean;
78
116
  }>) => React.ComponentType<T>;
79
- declare const withStytchSession: <T extends object>(Component: React.ComponentType<T & {
117
+ declare const withStytchSession: <T extends object, TAssumeHydrated extends boolean = false>(Component: React.ComponentType<T & {
80
118
  stytchSession: Session | null;
81
119
  stytchSessionIsInitialized: boolean;
82
120
  stytchSessionIsFromCache: boolean;
@@ -86,11 +124,25 @@ interface StytchProviderProps<TProjectConfiguration extends StytchProjectConfigu
86
124
  * A Stytch client instance, created using either {@link createStytchHeadlessClient} or {@link createStytchUIClient}
87
125
  */
88
126
  stytch: StytchClient<TProjectConfiguration>;
127
+ /**
128
+ * When true, the provider will assume that the component will only be
129
+ * rendered in a browser environment, either in a single-page application or
130
+ * after completing hydration of a server-rendered application. This allows
131
+ * cached values to be retrieved from the browser on the first render, meaning
132
+ * that the `isInitialized` value returned from Stytch hooks will be `true`
133
+ * starting from the first render.
134
+ *
135
+ * When `false`, the provider will defer initialization until after the first
136
+ * render, and `isInitialized` will initially be `false`.
137
+ *
138
+ * This value defaults to `false` in `@stytch/nextjs`.
139
+ */
140
+ assumeHydrated?: boolean;
89
141
  children?: ReactNode;
90
142
  }
91
143
  /**
92
144
  * The Stytch Context Provider.
93
- * Wrap your application with this component in `_app.js` in order to use Stytch everywhere in your app.
145
+ * Wrap your application with this component in order to use Stytch everywhere in your app.
94
146
  * @example
95
147
  * const stytch = createStytchHeadlessClient('public-token-<find yours in the stytch dashboard>')
96
148
  *
@@ -100,7 +152,7 @@ interface StytchProviderProps<TProjectConfiguration extends StytchProjectConfigu
100
152
  * </StytchProvider>
101
153
  * )
102
154
  */
103
- declare const StytchProvider: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>({ stytch, children }: StytchProviderProps<TProjectConfiguration>) => JSX.Element;
155
+ declare const StytchProvider: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>({ stytch, children, assumeHydrated }: StytchProviderProps<TProjectConfiguration>) => JSX.Element;
104
156
  interface StytchProps<TProjectConfiguration extends StytchProjectConfigurationInput = Stytch.DefaultProjectConfiguration> {
105
157
  /**
106
158
  * A {@link StytchLoginConfig} object. Add products and product-specific config to this object to change the login methods shown.
@@ -167,10 +219,10 @@ interface StytchProps<TProjectConfiguration extends StytchProjectConfigurationIn
167
219
  }
168
220
  /**
169
221
  * The Stytch Login Screen component.
170
- * This component can only be used with the Stytch UI Client - use {@link createStytchUIClient}
171
- * in your `_app.jsx` file.
222
+ * This component can only be used with a Stytch UI Client
223
+ * passed into the StytchProvider.
172
224
  *
173
- * See the {@link https://stytch.com/docs/sdks/javascript-sdk online reference}
225
+ * See the {@link https://stytch.com/docs/sdks online reference}
174
226
  *
175
227
  * @example
176
228
  * <StytchLogin
@@ -193,22 +245,21 @@ interface StytchProps<TProjectConfiguration extends StytchProjectConfigurationIn
193
245
  * onEvent: (event) => console.log(event)
194
246
  * }}
195
247
  * />
196
- *
197
- * @param config - A {@link StytchLoginConfig} object
198
- * @param styles - An optional {@link StyleConfig} to customize the look and feel of the screen.
199
- * @param callbacks - An optional {@link Callbacks} object
200
248
  */
201
249
  declare const StytchLogin: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>({ config, styles, callbacks }: StytchProps<TProjectConfiguration>) => React.JSX.Element;
202
250
  interface StytchResetPasswordProps<TProjectConfiguration extends StytchProjectConfigurationInput = Stytch.DefaultProjectConfiguration> extends StytchProps<TProjectConfiguration> {
251
+ /**
252
+ * A Stytch password reset token.
253
+ */
203
254
  passwordResetToken: string;
204
255
  }
205
256
  type IdentityProviderProps = Omit<StytchProps, "config">;
206
257
  /**
207
258
  * The Stytch Reset Password component.
208
- * This component can only be used with a {@link StytchUIClient} client constructor
209
- * passed into the {@link StytchProvider}
259
+ * This component can only be used with a Stytch UI Client
260
+ * passed into the StytchProvider.
210
261
  *
211
- * See the {@link https://stytch.com/docs/sdks/javascript-sdk online reference}
262
+ * See the {@link https://stytch.com/docs/sdks online reference}
212
263
  *
213
264
  * @example
214
265
  * <StytchPasswordReset
@@ -232,19 +283,14 @@ type IdentityProviderProps = Omit<StytchProps, "config">;
232
283
  * onEvent: (event) => console.log(event)
233
284
  * }}
234
285
  * />
235
- *
236
- * @param config - A {@link StytchLoginConfig} object
237
- * @param passwordResetToken - A Stytch password reset token
238
- * @param styles - An optional {@link StyleConfig} to customize the look and feel of the screen.
239
- * @param callbacks - An optional {@link Callbacks} object
240
286
  */
241
287
  declare const StytchPasswordReset: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>({ config, styles, callbacks, passwordResetToken }: StytchResetPasswordProps<TProjectConfiguration>) => React.JSX.Element;
242
288
  /**
243
289
  * The Stytch Passkey Registration component.
244
- * This component can only be used with a {@link StytchUIClient} client constructor
245
- * passed into the {@link StytchProvider}
290
+ * This component can only be used with a Stytch UI Client
291
+ * passed into the StytchProvider.
246
292
  *
247
- * See the {@link https://stytch.com/docs/sdks/javascript-sdk online reference}
293
+ * See the {@link https://stytch.com/docs/sdks online reference}
248
294
  *
249
295
  * @example
250
296
  * const styles = {
@@ -263,31 +309,27 @@ declare const StytchPasswordReset: <TProjectConfiguration extends Partial<import
263
309
  * onEvent: (event) => console.log(event)
264
310
  * }}
265
311
  * />
266
- * />
267
- *
268
- * @param styles - An optional {@link StyleConfig} to customize the look and feel of the screen.
269
- * @param callbacks - An optional {@link Callbacks} object
270
312
  */
271
313
  declare const StytchPasskeyRegistration: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>({ config, styles, callbacks }: StytchProps<TProjectConfiguration>) => React.JSX.Element;
272
314
  /**
273
315
  * The Stytch IDP component.
274
316
  * Parses OAuth Authorization params (client_id, scope, nonce, etc.) out of the page URL.
275
317
  * Requires the user to be logged in.
276
- * This component can only be used with a {@link StytchUIClient} client constructor
277
- * passed into the {@link StytchProvider}
318
+ * This component can only be used with a Stytch UI Client
319
+ * passed into the StytchProvider.
278
320
  *
279
- * See the {@link https://stytch.com/docs/sdks/javascript-sdk online reference}
321
+ * See the {@link https://stytch.com/docs/sdks online reference}
280
322
  *
281
323
  * @example
282
324
  * const styles = {
283
- * container: {
284
- * backgroundColor: '#e11e1e',
285
- * },
286
- * colors: {
287
- * primary: '#ff00f7',
288
- * secondary: '#5C727D',
289
- * },
290
- * }
325
+ * container: {
326
+ * backgroundColor: '#e11e1e',
327
+ * },
328
+ * colors: {
329
+ * primary: '#ff00f7',
330
+ * secondary: '#5C727D',
331
+ * },
332
+ * }
291
333
  *
292
334
  * <IdentityProvider
293
335
  * styles={styles}
@@ -295,11 +337,7 @@ declare const StytchPasskeyRegistration: <TProjectConfiguration extends Partial<
295
337
  * onEvent: (event) => console.log(event)
296
338
  * }}
297
339
  * />
298
- * />
299
- *
300
- * @param styles - An optional {@link StyleConfig} to customize the look and feel of the screen.
301
- * @param callbacks - An optional {@link Callbacks} object
302
340
  */
303
341
  declare const IdentityProvider: ({ styles, callbacks }: IdentityProviderProps) => React.JSX.Element;
304
- export { StytchProvider, useStytch, useStytchSession, useStytchUser, withStytch, withStytchSession, withStytchUser, StytchLogin, StytchPasswordReset, StytchPasskeyRegistration, IdentityProvider };
305
- export type { StytchProviderProps };
342
+ export { IdentityProvider, StytchLogin, StytchPasskeyRegistration, StytchPasswordReset, StytchProvider, useStytch, useStytchSession, useStytchUser, withStytch, withStytchSession, withStytchUser };
343
+ export type { StytchProviderProps, IdentityProviderProps, StytchProps, StytchResetPasswordProps };