@stytch/react 19.4.3 → 19.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 (52) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +7 -7
  3. package/b2b/headless/package.json +6 -0
  4. package/b2b/ui/package.json +6 -0
  5. package/dist/StytchB2BContext-9c062712.d.ts +272 -0
  6. package/dist/{StytchB2BContext-081081ee.js → StytchB2BContext-9c062712.js} +94 -49
  7. package/dist/StytchB2BContext-c5062f9b.d.ts +272 -0
  8. package/dist/StytchB2BContext-c5062f9b.js +280 -0
  9. package/dist/StytchSSRProxy-34c789b5.d.ts +3 -0
  10. package/dist/StytchSSRProxy-34c789b5.js +48 -0
  11. package/dist/StytchSSRProxy-86bc42b3.d.ts +3 -0
  12. package/dist/StytchSSRProxy-86bc42b3.js +54 -0
  13. package/dist/adminPortal/index.d.ts +1 -1
  14. package/dist/adminPortal/index.esm.d.ts +1 -1
  15. package/dist/adminPortal/index.esm.js +5 -4
  16. package/dist/adminPortal/index.js +5 -4
  17. package/dist/b2b/index.d.ts +180 -19
  18. package/dist/b2b/index.esm.d.ts +180 -19
  19. package/dist/b2b/index.esm.js +91 -18
  20. package/dist/b2b/index.headless.d.ts +16 -0
  21. package/dist/b2b/index.headless.esm.d.ts +16 -0
  22. package/dist/b2b/index.headless.esm.js +24 -0
  23. package/dist/b2b/index.headless.js +28 -0
  24. package/dist/b2b/index.js +99 -26
  25. package/dist/b2b/index.ui.d.ts +17 -0
  26. package/dist/b2b/index.ui.esm.d.ts +17 -0
  27. package/dist/b2b/index.ui.esm.js +25 -0
  28. package/dist/b2b/index.ui.js +29 -0
  29. package/dist/errors-d9d5fbc8.d.ts +5 -0
  30. package/dist/index-b14d4efe.d.ts +1 -1
  31. package/dist/index.d.ts +134 -77
  32. package/dist/index.esm.d.ts +134 -77
  33. package/dist/index.esm.js +153 -94
  34. package/dist/index.headless.d.ts +16 -0
  35. package/dist/index.headless.esm.d.ts +16 -0
  36. package/dist/index.headless.esm.js +24 -0
  37. package/dist/index.headless.js +28 -0
  38. package/dist/index.js +167 -108
  39. package/dist/index.ui.d.ts +17 -0
  40. package/dist/index.ui.esm.d.ts +17 -0
  41. package/dist/index.ui.esm.js +25 -0
  42. package/dist/index.ui.js +29 -0
  43. package/dist/useIsomorphicLayoutEffect-1babb81e.d.ts +24 -0
  44. package/dist/{invariant-568a7633.js → useIsomorphicLayoutEffect-1babb81e.js} +5 -13
  45. package/dist/useIsomorphicLayoutEffect-65746ef3.d.ts +24 -0
  46. package/dist/{invariant-ae5a5bce.js → useIsomorphicLayoutEffect-65746ef3.js} +4 -16
  47. package/package.json +5 -3
  48. package/dist/StytchB2BContext-081081ee.d.ts +0 -165
  49. package/dist/StytchB2BContext-865b6947.d.ts +0 -165
  50. package/dist/StytchB2BContext-865b6947.js +0 -235
  51. package/dist/invariant-568a7633.d.ts +0 -27
  52. package/dist/invariant-ae5a5bce.d.ts +0 -27
package/dist/index.esm.js CHANGED
@@ -1,13 +1,16 @@
1
- import React, { createContext, useContext, useMemo, useEffect, useRef, useLayoutEffect } from 'react';
2
- import { i as invariant, u as useAsyncState, m as mergeWithStableProps, n as noProviderError, p as providerMustBeUniqueError, a as noSSRError, b as noHeadlessClientError } from './invariant-568a7633.js';
1
+ import React, { createContext, useContext, useMemo, useCallback, useRef, useEffect } from 'react';
2
+ import { i as invariant, u as useAsyncState, m as mergeWithStableProps, a as useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect-1babb81e.js';
3
+ import { n as noProviderError, p as providerMustBeUniqueError, i as isStytchSSRProxy, a as noHeadlessClientError } from './StytchSSRProxy-34c789b5.js';
3
4
 
4
5
  const initialUser = {
5
6
  user: null,
6
7
  fromCache: false,
8
+ isInitialized: false,
7
9
  };
8
10
  const initialSession = {
9
11
  session: null,
10
12
  fromCache: false,
13
+ isInitialized: false,
11
14
  };
12
15
  const StytchContext = createContext({ isMounted: false });
13
16
  const StytchUserContext = createContext(initialUser);
@@ -18,28 +21,37 @@ const isUIClient = (client) => {
18
21
  };
19
22
  /**
20
23
  * Returns the active User.
24
+ * The Stytch SDKs are used for client-side authentication and session management.
25
+ * Check the isInitialized property to determine if the SDK has completed initialization.
21
26
  * Check the fromCache property to determine if the user data is from persistent storage.
22
27
  * @example
23
- * const {user} = useStytchUser();
28
+ * const {user, isInitialized, fromCache} = useStytchUser();
29
+ * if (!isInitialized) {
30
+ * return <p>Loading...</p>;
31
+ * }
24
32
  * return (<h1>Welcome, {user.name.first_name}</h1>);
25
- * @returns A {@link SWRUser}
26
33
  */
27
- const useStytchUser = () => {
34
+ const useStytchUser$1 = () => {
28
35
  invariant(useIsMounted__INTERNAL(), noProviderError('useStytchUser'));
29
36
  return useContext(StytchUserContext);
30
37
  };
31
38
  /**
32
39
  * Returns the active user's Stytch session.
40
+ * The Stytch SDKs are used for client-side authentication and session management.
41
+ * Check the isInitialized property to determine if the SDK has completed initialization.
42
+ * Check the fromCache property to determine if the session data is from persistent storage.
33
43
  * @example
34
- * const {session} = useStytchSession();
44
+ * const {session, isInitialized, fromCache} = useStytchSession();
35
45
  * useEffect(() => {
46
+ * if (!isInitialized) {
47
+ * return;
48
+ * }
36
49
  * if (!session) {
37
50
  * router.replace('/login')
38
51
  * }
39
- * }, [session]);
40
- * @returns A {@link SWRSession}
52
+ * }, [session, isInitialized]);
41
53
  */
42
- const useStytchSession = () => {
54
+ const useStytchSession$1 = () => {
43
55
  invariant(useIsMounted__INTERNAL(), noProviderError('useStytchSession'));
44
56
  return useContext(StytchSessionContext);
45
57
  };
@@ -65,54 +77,68 @@ const withStytch = (Component) => {
65
77
  WithStytch.displayName = `withStytch(${Component.displayName || Component.name || 'Component'})`;
66
78
  return WithStytch;
67
79
  };
68
- const withStytchUser = (Component) => {
80
+ const withStytchUser$1 = (Component) => {
69
81
  const WithStytchUser = (props) => {
70
82
  invariant(useIsMounted__INTERNAL(), noProviderError('withStytchUser'));
71
- const { user, fromCache } = useStytchUser();
72
- return React.createElement(Component, Object.assign({}, props, { stytchUser: user, stytchUserIsFromCache: fromCache }));
83
+ const { user, isInitialized, fromCache } = useStytchUser$1();
84
+ return (React.createElement(Component, Object.assign({}, props, { stytchUser: user, stytchUserIsInitialized: isInitialized, stytchUserIsFromCache: fromCache })));
73
85
  };
74
86
  WithStytchUser.displayName = `withStytchUser(${Component.displayName || Component.name || 'Component'})`;
75
87
  return WithStytchUser;
76
88
  };
77
- const withStytchSession = (Component) => {
89
+ const withStytchSession$1 = (Component) => {
78
90
  const WithStytchSession = (props) => {
79
91
  invariant(useIsMounted__INTERNAL(), noProviderError('withStytchSession'));
80
- const { session, fromCache } = useStytchSession();
81
- return React.createElement(Component, Object.assign({}, props, { stytchSession: session, stytchSessionIsFromCache: fromCache }));
92
+ const { session, isInitialized, fromCache } = useStytchSession$1();
93
+ return (React.createElement(Component, Object.assign({}, props, { stytchSession: session, stytchSessionIsInitialized: isInitialized, stytchSessionIsFromCache: fromCache })));
82
94
  };
83
95
  WithStytchSession.displayName = `withStytchSession(${Component.displayName || Component.name || 'Component'})`;
84
96
  return WithStytchSession;
85
97
  };
86
98
  /**
87
99
  * The Stytch Context Provider.
88
- * Wrap your application with this component in the root file in order to use Stytch everywhere in your app.
100
+ * Wrap your application with this component in order to use Stytch everywhere in your app.
89
101
  * @example
90
- * const stytch = new StytchHeadlessClient('public-token-<find yours in the stytch dashboard>')
102
+ * const stytch = createStytchHeadlessClient('public-token-<find yours in the stytch dashboard>')
91
103
  *
92
- * ReactDOM.render(
104
+ * return (
93
105
  * <StytchProvider stytch={stytch}>
94
106
  * <App />
95
- * </StytchProvider>,
96
- * document.getElementById('root'),
107
+ * </StytchProvider>
97
108
  * )
98
109
  */
99
- const StytchProvider = ({ stytch, children, }) => {
110
+ const StytchProvider$1 = ({ stytch, children, assumeHydrated = false, }) => {
100
111
  invariant(!useIsMounted__INTERNAL(), providerMustBeUniqueError);
101
- invariant(typeof window !== 'undefined', noSSRError);
112
+ invariant(!assumeHydrated || typeof window !== 'undefined', 'The `assumeHydrated` prop must be set to `false` when using StytchProvider in a server environment.');
102
113
  const ctx = useMemo(() => ({ client: stytch, isMounted: true }), [stytch]);
103
- const [{ user, session }, setClientState] = useAsyncState({
104
- session: stytch.session.getInfo(),
105
- user: stytch.user.getInfo(),
106
- });
107
- useEffect(() => stytch.onStateChange(() => {
108
- setClientState((oldState) => {
109
- const newState = {
110
- session: stytch.session.getInfo(),
111
- user: stytch.user.getInfo(),
112
- };
113
- return mergeWithStableProps(oldState, newState);
114
- });
115
- }), [setClientState, stytch]);
114
+ const getHydratedState = useCallback(() => {
115
+ return {
116
+ session: Object.assign(Object.assign({}, stytch.session.getInfo()), { isInitialized: true }),
117
+ user: Object.assign(Object.assign({}, stytch.user.getInfo()), { isInitialized: true }),
118
+ };
119
+ }, [stytch]);
120
+ const getInitialState = () => {
121
+ return {
122
+ session: initialSession,
123
+ user: initialUser,
124
+ };
125
+ };
126
+ const [{ user, session }, setClientState] = useAsyncState(() => assumeHydrated ? getHydratedState() : getInitialState());
127
+ // Store the initial value of `assumeHydrated` in a ref, because it is
128
+ // logically only relevant for the first render
129
+ const assumeHydratedRef = useRef(assumeHydrated);
130
+ useEffect(() => {
131
+ if (isStytchSSRProxy(stytch)) {
132
+ return;
133
+ }
134
+ const updateState = () => {
135
+ setClientState((oldState) => mergeWithStableProps(oldState, getHydratedState()));
136
+ };
137
+ if (!assumeHydratedRef.current) {
138
+ updateState();
139
+ }
140
+ return stytch.onStateChange(updateState);
141
+ }, [getHydratedState, setClientState, stytch]);
116
142
  return (React.createElement(StytchContext.Provider, { value: ctx },
117
143
  React.createElement(StytchUserContext.Provider, { value: user },
118
144
  React.createElement(StytchSessionContext.Provider, { value: session }, children))));
@@ -120,10 +146,10 @@ const StytchProvider = ({ stytch, children, }) => {
120
146
 
121
147
  /**
122
148
  * The Stytch Login Screen component.
123
- * This component can only be used with a {@link StytchUIClient} client constructor
124
- * passed into the {@link StytchProvider}
149
+ * This component can only be used with a Stytch UI Client
150
+ * passed into the StytchProvider.
125
151
  *
126
- * See the {@link https://stytch.com/docs/sdks/javascript-sdk online reference}
152
+ * See the {@link https://stytch.com/docs/sdks online reference}
127
153
  *
128
154
  * @example
129
155
  * <StytchLogin
@@ -146,13 +172,12 @@ const StytchProvider = ({ stytch, children, }) => {
146
172
  * onEvent: (event) => console.log(event)
147
173
  * }}
148
174
  * />
149
- * @param props {@link StytchProps}
150
175
  */
151
176
  const StytchLogin = ({ config, styles, callbacks, }) => {
152
177
  invariant(useIsMounted__INTERNAL(), noProviderError('<StytchLogin />'));
153
178
  const stytchClient = useStytch();
154
179
  const containerEl = useRef(null);
155
- useLayoutEffect(() => {
180
+ useIsomorphicLayoutEffect(() => {
156
181
  if (!isUIClient(stytchClient)) {
157
182
  throw Error(noHeadlessClientError);
158
183
  }
@@ -164,7 +189,7 @@ const StytchLogin = ({ config, styles, callbacks, }) => {
164
189
  containerEl.current.id = `stytch-magic-link-${randId}`;
165
190
  }
166
191
  stytchClient.mountLogin({
167
- config: config,
192
+ config,
168
193
  callbacks,
169
194
  elementId: `#${containerEl.current.id}`,
170
195
  styles,
@@ -174,10 +199,10 @@ const StytchLogin = ({ config, styles, callbacks, }) => {
174
199
  };
175
200
  /**
176
201
  * The Stytch Reset Password component.
177
- * This component can only be used with a {@link StytchUIClient} client constructor
178
- * passed into the {@link StytchProvider}
202
+ * This component can only be used with a Stytch UI Client
203
+ * passed into the StytchProvider.
179
204
  *
180
- * See the {@link https://stytch.com/docs/sdks/javascript-sdk online reference}
205
+ * See the {@link https://stytch.com/docs/sdks online reference}
181
206
  *
182
207
  * @example
183
208
  * <StytchPasswordReset
@@ -201,17 +226,12 @@ const StytchLogin = ({ config, styles, callbacks, }) => {
201
226
  * onEvent: (event) => console.log(event)
202
227
  * }}
203
228
  * />
204
- *
205
- * @param config - A {@link StytchLoginConfig} object
206
- * @param passwordResetToken - A Stytch password reset token
207
- * @param styles - An optional {@link StyleConfig} to customize the look and feel of the screen.
208
- * @param callbacks - An optional {@link Callbacks} object
209
229
  */
210
230
  const StytchPasswordReset = ({ config, styles, callbacks, passwordResetToken, }) => {
211
231
  invariant(useIsMounted__INTERNAL(), noProviderError('<StytchResetPassword />'));
212
232
  const stytchClient = useStytch();
213
233
  const containerEl = useRef(null);
214
- useLayoutEffect(() => {
234
+ useIsomorphicLayoutEffect(() => {
215
235
  if (!isUIClient(stytchClient)) {
216
236
  throw Error(noHeadlessClientError);
217
237
  }
@@ -224,7 +244,7 @@ const StytchPasswordReset = ({ config, styles, callbacks, passwordResetToken, })
224
244
  }
225
245
  if (passwordResetToken) {
226
246
  stytchClient.mountResetPassword({
227
- config: config,
247
+ config,
228
248
  callbacks,
229
249
  elementId: `#${containerEl.current.id}`,
230
250
  styles,
@@ -234,44 +254,37 @@ const StytchPasswordReset = ({ config, styles, callbacks, passwordResetToken, })
234
254
  }, [stytchClient, config, styles, callbacks, passwordResetToken]);
235
255
  return React.createElement("div", { ref: containerEl });
236
256
  };
257
+ /**
258
+ * The Stytch Passkey Registration component.
259
+ * This component can only be used with a Stytch UI Client
260
+ * passed into the StytchProvider.
261
+ *
262
+ * See the {@link https://stytch.com/docs/sdks online reference}
263
+ *
264
+ * @example
265
+ * const styles = {
266
+ * container: {
267
+ * backgroundColor: '#e11e1e',
268
+ * },
269
+ * colors: {
270
+ * primary: '#ff00f7',
271
+ * secondary: '#5C727D',
272
+ * },
273
+ * }
274
+ *
275
+ * <StytchPasskeyRegistration
276
+ * styles={styles}
277
+ * callbacks={{
278
+ * onEvent: (event) => console.log(event)
279
+ * }}
280
+ * />
281
+ */
237
282
  const StytchPasskeyRegistration = ({ config, styles, callbacks, }) => {
238
- /**
239
- * The Stytch Passkey Registration component.
240
- * This component can only be used with a {@link StytchUIClient} client constructor
241
- * passed into the {@link StytchProvider}
242
- *
243
- * See the {@link https://stytch.com/docs/sdks/javascript-sdk online reference}
244
- *
245
- *
246
- * @example
247
- * const styles = {
248
- * container: {
249
- * backgroundColor: '#e11e1e',
250
- * },
251
- * colors: {
252
- * primary: '#ff00f7',
253
- * secondary: '#5C727D',
254
- * },
255
- * }
256
- *
257
- * <StytchPasskeyRegistration
258
- * config={{
259
- * products: ['passkey'],
260
- * }}
261
- * styles={styles}
262
- * callbacks={{
263
- * onEvent: (event) => console.log(event)
264
- * }}
265
- * />
266
- * @param config - A {@link StytchLoginConfig} object
267
- * @param styles - An optional {@link StyleConfig} to customize the look and feel of the screen.
268
- * @param callbacks - An optional {@link Callbacks} object
269
- */
270
283
  invariant(useIsMounted__INTERNAL(), noProviderError('<StytchPasskeyRegistration />'));
271
284
  const stytchClient = useStytch();
272
- const user = useStytchUser();
285
+ const user = useStytchUser$1();
273
286
  const containerEl = useRef(null);
274
- useLayoutEffect(() => {
287
+ useIsomorphicLayoutEffect(() => {
275
288
  if (!isUIClient(stytchClient)) {
276
289
  throw Error(noHeadlessClientError);
277
290
  }
@@ -280,7 +293,7 @@ const StytchPasskeyRegistration = ({ config, styles, callbacks, }) => {
280
293
  }
281
294
  if (!containerEl.current.id) {
282
295
  const randId = Math.floor(Math.random() * 1e6);
283
- containerEl.current.id = `stytch-reset-passkey-${randId}`;
296
+ containerEl.current.id = `stytch-passkey-registration-${randId}`;
284
297
  }
285
298
  stytchClient.mountPasskeyRegistration({
286
299
  config,
@@ -295,11 +308,10 @@ const StytchPasskeyRegistration = ({ config, styles, callbacks, }) => {
295
308
  * The Stytch IDP component.
296
309
  * Parses OAuth Authorization params (client_id, scope, nonce, etc.) out of the page URL.
297
310
  * Requires the user to be logged in.
298
- * This component can only be used with a {@link StytchUIClient} client constructor
299
- * passed into the {@link StytchProvider}
300
- *
301
- * See the {@link https://stytch.com/docs/sdks/javascript-sdk online reference}
311
+ * This component can only be used with a Stytch UI Client
312
+ * passed into the StytchProvider.
302
313
  *
314
+ * See the {@link https://stytch.com/docs/sdks online reference}
303
315
  *
304
316
  * @example
305
317
  * const styles = {
@@ -318,15 +330,13 @@ const StytchPasskeyRegistration = ({ config, styles, callbacks, }) => {
318
330
  * onEvent: (event) => console.log(event)
319
331
  * }}
320
332
  * />
321
- * @param styles - An optional {@link StyleConfig} to customize the look and feel of the screen.
322
- * @param callbacks - An optional {@link Callbacks} object
323
333
  */
324
334
  const IdentityProvider = ({ styles, callbacks }) => {
325
335
  invariant(useIsMounted__INTERNAL(), noProviderError('<IdentityProvider />'));
326
336
  const stytchClient = useStytch();
327
- const user = useStytchUser();
337
+ const user = useStytchUser$1();
328
338
  const containerEl = useRef(null);
329
- useLayoutEffect(() => {
339
+ useIsomorphicLayoutEffect(() => {
330
340
  if (!isUIClient(stytchClient)) {
331
341
  throw Error(noHeadlessClientError);
332
342
  }
@@ -346,4 +356,53 @@ const IdentityProvider = ({ styles, callbacks }) => {
346
356
  return React.createElement("div", { ref: containerEl });
347
357
  };
348
358
 
359
+ /**
360
+ * Returns the active User.
361
+ * The Stytch SDKs are used for client-side authentication and session management.
362
+ * Check the isInitialized property to determine if the SDK has completed initialization.
363
+ * Check the fromCache property to determine if the user data is from persistent storage.
364
+ * @example
365
+ * const {user, isInitialized, fromCache} = useStytchUser();
366
+ * if (!isInitialized) {
367
+ * return <p>Loading...</p>;
368
+ * }
369
+ * return (<h1>Welcome, {user.name.first_name}</h1>);
370
+ */
371
+ const useStytchUser = useStytchUser$1;
372
+ /**
373
+ * Returns the active user's Stytch session.
374
+ * The Stytch SDKs are used for client-side authentication and session management.
375
+ * Check the isInitialized property to determine if the SDK has completed initialization.
376
+ * Check the fromCache property to determine if the session data is from persistent storage.
377
+ * @example
378
+ * const {session, isInitialized, fromCache} = useStytchSession();
379
+ * useEffect(() => {
380
+ * if (!isInitialized) {
381
+ * return;
382
+ * }
383
+ * if (!session) {
384
+ * router.replace('/login')
385
+ * }
386
+ * }, [session, isInitialized]);
387
+ */
388
+ const useStytchSession = useStytchSession$1;
389
+ const withStytchUser = withStytchUser$1;
390
+ const withStytchSession = withStytchSession$1;
391
+ /**
392
+ * The Stytch Context Provider.
393
+ * Wrap your application with this component in order to use Stytch everywhere in your app.
394
+ * @example
395
+ * const stytch = createStytchHeadlessClient('public-token-<find yours in the stytch dashboard>')
396
+ *
397
+ * ReactDOM.render(
398
+ * <StytchProvider stytch={stytch}>
399
+ * <App />
400
+ * </StytchProvider>,
401
+ * document.getElementById('root'),
402
+ * )
403
+ */
404
+ const StytchProvider = ({ stytch, children, assumeHydrated = true, }) => {
405
+ return (React.createElement(StytchProvider$1, { stytch: stytch, assumeHydrated: assumeHydrated }, children));
406
+ };
407
+
349
408
  export { IdentityProvider, StytchLogin, StytchPasskeyRegistration, StytchPasswordReset, StytchProvider, useStytch, useStytchSession, useStytchUser, withStytch, withStytchSession, withStytchUser };
@@ -0,0 +1,16 @@
1
+ import { StytchHeadlessClient } from "@stytch/vanilla-js/headless";
2
+ /**
3
+ * Creates a Headless Stytch client object to call the stytch APIs.
4
+ * The Stytch client is not available serverside.
5
+ * @example
6
+ * const stytch = createStytchHeadlessClient('public-token-<find yours in the stytch dashboard>')
7
+ *
8
+ * return (
9
+ * <StytchProvider stytch={stytch}>
10
+ * <App />
11
+ * </StytchProvider>
12
+ * )
13
+ * @returns A {@link StytchHeadlessClient}
14
+ */
15
+ declare const createStytchHeadlessClient: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>(_PUBLIC_TOKEN: string, options?: import("@stytch/core/public").StytchClientOptions | undefined) => StytchHeadlessClient<TProjectConfiguration>;
16
+ export { createStytchHeadlessClient };
@@ -0,0 +1,16 @@
1
+ import { StytchHeadlessClient } from "@stytch/vanilla-js/headless";
2
+ /**
3
+ * Creates a Headless Stytch client object to call the stytch APIs.
4
+ * The Stytch client is not available serverside.
5
+ * @example
6
+ * const stytch = createStytchHeadlessClient('public-token-<find yours in the stytch dashboard>')
7
+ *
8
+ * return (
9
+ * <StytchProvider stytch={stytch}>
10
+ * <App />
11
+ * </StytchProvider>
12
+ * )
13
+ * @returns A {@link StytchHeadlessClient}
14
+ */
15
+ declare const createStytchHeadlessClient: <TProjectConfiguration extends Partial<import("@stytch/core/public").StytchProjectConfiguration> = Stytch.DefaultProjectConfiguration>(_PUBLIC_TOKEN: string, options?: import("@stytch/core/public").StytchClientOptions | undefined) => StytchHeadlessClient<TProjectConfiguration>;
16
+ export { createStytchHeadlessClient };
@@ -0,0 +1,24 @@
1
+ import { StytchHeadlessClient } from '@stytch/vanilla-js/headless';
2
+ import { c as createStytchSSRProxy } from './StytchSSRProxy-34c789b5.js';
3
+
4
+ /**
5
+ * Creates a Headless Stytch client object to call the stytch APIs.
6
+ * The Stytch client is not available serverside.
7
+ * @example
8
+ * const stytch = createStytchHeadlessClient('public-token-<find yours in the stytch dashboard>')
9
+ *
10
+ * return (
11
+ * <StytchProvider stytch={stytch}>
12
+ * <App />
13
+ * </StytchProvider>
14
+ * )
15
+ * @returns A {@link StytchHeadlessClient}
16
+ */
17
+ const createStytchHeadlessClient = (...args) => {
18
+ if (typeof window === 'undefined') {
19
+ return createStytchSSRProxy();
20
+ }
21
+ return new StytchHeadlessClient(...args);
22
+ };
23
+
24
+ export { createStytchHeadlessClient };
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var headless = require('@stytch/vanilla-js/headless');
6
+ var StytchSSRProxy = require('./StytchSSRProxy-86bc42b3.js');
7
+
8
+ /**
9
+ * Creates a Headless Stytch client object to call the stytch APIs.
10
+ * The Stytch client is not available serverside.
11
+ * @example
12
+ * const stytch = createStytchHeadlessClient('public-token-<find yours in the stytch dashboard>')
13
+ *
14
+ * return (
15
+ * <StytchProvider stytch={stytch}>
16
+ * <App />
17
+ * </StytchProvider>
18
+ * )
19
+ * @returns A {@link StytchHeadlessClient}
20
+ */
21
+ const createStytchHeadlessClient = (...args) => {
22
+ if (typeof window === 'undefined') {
23
+ return StytchSSRProxy.createStytchSSRProxy();
24
+ }
25
+ return new headless.StytchHeadlessClient(...args);
26
+ };
27
+
28
+ exports.createStytchHeadlessClient = createStytchHeadlessClient;