@stytch/nextjs 11.0.0 → 12.0.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # @stytch/nextjs
2
2
 
3
+ ## 12.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 5dd9d24: Change export of B2B Headless Client to seperate subpackage to improve tree-shaking performance
8
+
9
+ Two public export locations have changed:
10
+
11
+ ```javascript
12
+ import { createStytchB2BHeadlessClient } from '@stytch/nextjs/b2b';
13
+ ```
14
+
15
+ Is now updated to
16
+
17
+ ```javascript
18
+ import { createStytchB2BHeadlessClient } from '@stytch/vanilla-js/b2b/headless';
19
+ ```
20
+
21
+ ```javascript
22
+ import { createStytchB2BUIClient } from '@stytch/nextjs/b2b';
23
+ ```
24
+
25
+ Is now updated to
26
+
27
+ ```javascript
28
+ import { createStytchB2BUIClient } from '@stytch/vanilla-js/b2b/ui';
29
+ ```
30
+
31
+ ### Patch Changes
32
+
33
+ - Updated dependencies [5dd9d24]
34
+ - @stytch/vanilla-js@3.0.0
35
+
3
36
  ## 11.0.0
4
37
 
5
38
  ### Patch Changes
package/README.md CHANGED
@@ -9,6 +9,22 @@ With `npm`
9
9
 
10
10
  ## Documentation
11
11
 
12
+ This package contains several entrypoints, depending on if you are using the B2B or B2C stytch product.
13
+
14
+ ```javascript
15
+ // Stytch B2C Product
16
+ import { StytchProvider } from '@stytch/nextjs';
17
+ import { createStytchUIClient } from '@stytch/nextjs/ui';
18
+ // The headless client does not bundle UI elements, and is a much smaller package
19
+ import { createStytchHeadlessClient } from '@stytch/nextjs/headless';
20
+
21
+ // Stytch B2B Product
22
+ import { StytchB2B } from '@stytch/nextjs/b2b';
23
+ import { createStytchB2BUIClient } from '@stytch/nextjs/b2b/ui';
24
+ // The headless client does not bundle UI elements, and is a much smaller package
25
+ import { createStytchB2BHeadlessClient } from '@stytch/nextjs/b2b/headless';
26
+ ```
27
+
12
28
  For full documentation please refer to Stytch's javascript SDK documentation on https://stytch.com/docs/sdks.
13
29
 
14
30
  ## Example Usage
@@ -0,0 +1,6 @@
1
+ {
2
+ "internal": true,
3
+ "main": "../../dist/b2b/index.headless.js",
4
+ "module": "../../dist/b2b/index.headless.esm.js",
5
+ "types": "../../dist/b2b/index.headless.d.ts"
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "internal": true,
3
+ "main": "../../dist/b2b/index.ui.js",
4
+ "module": "../../dist/b2b/index.ui.esm.js",
5
+ "types": "../../dist/b2b/index.ui.d.ts"
6
+ }
@@ -1,10 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  import React from "react";
3
3
  import { ReactNode } from "react";
4
- import { StytchB2BHeadlessClient, StytchB2BUIClient, Member, MemberSession } from "@stytch/vanilla-js/b2b/";
4
+ import { Member, MemberSession, StytchB2BUIClient } from "@stytch/vanilla-js/b2b";
5
+ import { StytchB2BHeadlessClient } from "@stytch/vanilla-js/b2b/headless";
5
6
  import { Callbacks, StyleConfig, StytchB2BUIConfig } from "@stytch/vanilla-js";
6
- import { StytchB2BHeadlessClient as StytchB2BHeadlessClient$0 } from "@stytch/vanilla-js/b2b";
7
- import { StytchB2BUIClient as StytchB2BUIClient$0 } from "@stytch/vanilla-js/b2b";
8
7
  /**
9
8
  * The Stytch Client object passed in to <StytchProvider /> in your `_app.js`.
10
9
  * Either a StytchUIClient or StytchHeadlessClient.
@@ -205,34 +204,5 @@ interface StytchB2BProps {
205
204
  * @param props {@link StytchB2BProps}
206
205
  */
207
206
  declare const StytchB2B: ({ styles, callbacks, config }: StytchB2BProps) => React.JSX.Element;
208
- /**
209
- * Creates a Headless Stytch client object to call the stytch B2B APIs.
210
- * The Stytch client is not available serverside.
211
- * @example
212
- * const stytch = createStytchB2BHeadlessClient('public-token-<find yours in the stytch dashboard>')
213
- *
214
- * return (
215
- * <StytchB2BProvider stytch={stytch}>
216
- * <App />
217
- * </StytchB2BProvider>
218
- * )
219
- * @returns A {@link StytchHeadlessClient}
220
- */
221
- declare const createStytchB2BHeadlessClient: (_PUBLIC_TOKEN: string, options?: import("@stytch/core/dist/public").StytchClientOptions | undefined) => StytchB2BHeadlessClient$0;
222
- /**
223
- * Creates a Stytch UI client object to call the Stytch APIs and render Stytch UI components.
224
- * The Stytch client is not available serverside.
225
- * If you do not use Stytch UI components, use {@link createStytchB2BHeadlessClient} to reduce your bundle size.
226
- * @example
227
- * const stytch = createStytchB2BUIClient('public-token-<find yours in the stytch dashboard>')
228
- *
229
- * return (
230
- * <StytchB2BProvider stytch={stytch}>
231
- * <App />
232
- * </StytchB2BProvider>
233
- * )
234
- * @returns A {@link StytchB2BUIClient}
235
- */
236
- declare const createStytchB2BUIClient: (_PUBLIC_TOKEN: string, options?: import("@stytch/core/dist/public").StytchClientOptions | undefined) => StytchB2BUIClient$0;
237
- export { StytchB2BProvider, useStytchB2BClient, useStytchMemberSession, useStytchMember, withStytchB2BClient, withStytchMemberSession, withStytchMember, StytchB2B, createStytchB2BHeadlessClient, createStytchB2BUIClient };
207
+ export { StytchB2BProvider, useStytchB2BClient, useStytchMemberSession, useStytchMember, withStytchB2BClient, withStytchMemberSession, withStytchMember, StytchB2B };
238
208
  export type { StytchB2BProviderProps };
@@ -1,10 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  import React from "react";
3
3
  import { ReactNode } from "react";
4
- import { StytchB2BHeadlessClient, StytchB2BUIClient, Member, MemberSession } from "@stytch/vanilla-js/b2b/";
4
+ import { Member, MemberSession, StytchB2BUIClient } from "@stytch/vanilla-js/b2b";
5
+ import { StytchB2BHeadlessClient } from "@stytch/vanilla-js/b2b/headless";
5
6
  import { Callbacks, StyleConfig, StytchB2BUIConfig } from "@stytch/vanilla-js";
6
- import { StytchB2BHeadlessClient as StytchB2BHeadlessClient$0 } from "@stytch/vanilla-js/b2b";
7
- import { StytchB2BUIClient as StytchB2BUIClient$0 } from "@stytch/vanilla-js/b2b";
8
7
  /**
9
8
  * The Stytch Client object passed in to <StytchProvider /> in your `_app.js`.
10
9
  * Either a StytchUIClient or StytchHeadlessClient.
@@ -205,34 +204,5 @@ interface StytchB2BProps {
205
204
  * @param props {@link StytchB2BProps}
206
205
  */
207
206
  declare const StytchB2B: ({ styles, callbacks, config }: StytchB2BProps) => React.JSX.Element;
208
- /**
209
- * Creates a Headless Stytch client object to call the stytch B2B APIs.
210
- * The Stytch client is not available serverside.
211
- * @example
212
- * const stytch = createStytchB2BHeadlessClient('public-token-<find yours in the stytch dashboard>')
213
- *
214
- * return (
215
- * <StytchB2BProvider stytch={stytch}>
216
- * <App />
217
- * </StytchB2BProvider>
218
- * )
219
- * @returns A {@link StytchHeadlessClient}
220
- */
221
- declare const createStytchB2BHeadlessClient: (_PUBLIC_TOKEN: string, options?: import("@stytch/core/dist/public").StytchClientOptions | undefined) => StytchB2BHeadlessClient$0;
222
- /**
223
- * Creates a Stytch UI client object to call the Stytch APIs and render Stytch UI components.
224
- * The Stytch client is not available serverside.
225
- * If you do not use Stytch UI components, use {@link createStytchB2BHeadlessClient} to reduce your bundle size.
226
- * @example
227
- * const stytch = createStytchB2BUIClient('public-token-<find yours in the stytch dashboard>')
228
- *
229
- * return (
230
- * <StytchB2BProvider stytch={stytch}>
231
- * <App />
232
- * </StytchB2BProvider>
233
- * )
234
- * @returns A {@link StytchB2BUIClient}
235
- */
236
- declare const createStytchB2BUIClient: (_PUBLIC_TOKEN: string, options?: import("@stytch/core/dist/public").StytchClientOptions | undefined) => StytchB2BUIClient$0;
237
- export { StytchB2BProvider, useStytchB2BClient, useStytchMemberSession, useStytchMember, withStytchB2BClient, withStytchMemberSession, withStytchMember, StytchB2B, createStytchB2BHeadlessClient, createStytchB2BUIClient };
207
+ export { StytchB2BProvider, useStytchB2BClient, useStytchMemberSession, useStytchMember, withStytchB2BClient, withStytchMemberSession, withStytchMember, StytchB2B };
238
208
  export type { StytchB2BProviderProps };
@@ -1,28 +1,9 @@
1
1
  import React, { useRef, useState, useEffect, useCallback, createContext, useContext, useMemo, useLayoutEffect } from 'react';
2
- import { StytchB2BHeadlessClient, StytchB2BUIClient } from '@stytch/vanilla-js/b2b';
3
2
 
4
3
  const noProviderError = (item, provider = 'StytchProvider') => `${item} can only be used inside <${provider}>.`;
5
4
  const noHeadlessClientError = `Tried to create a Stytch Login UI element using the Stytch Headless SDK.
6
5
  You must use the UI SDK to use UI elements.
7
6
  Please make sure you are importing createStytchHeadlessClient from @stytch/nextjs/ui and not from @stytch/nextjs/headless.`;
8
- const cannotInvokeMethodOnServerError = (path) => `[Stytch] Invalid serverside function call to ${path}.
9
- The Stytch Javascript SDK is intended to ony be used on the client side.
10
- Make sure to wrap your API calls in a hook to ensure they are executed on the client.
11
- \`\`\`
12
- const myComponent = () => {
13
- const stytch = useStytch();
14
- // This will error out on the server.
15
- stytch.magicLinks.authenticate(...);
16
- useEffect(() => {
17
- // This will work well
18
- stytch.magicLinks.authenticate(...);
19
- }, []);
20
- }
21
- \`\`\`
22
-
23
- If you want to make API calls from server environments, please use the Stytch Node Library
24
- https://www.npmjs.com/package/stytch.
25
- `;
26
7
 
27
8
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
9
  function invariant(cond, message) {
@@ -52,23 +33,6 @@ const SSRStubKey = Symbol('__stytch_SSRStubKey');
52
33
  const isStytchSSRProxy = (proxy) => {
53
34
  return !!proxy[SSRStubKey];
54
35
  };
55
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
- const createProxy = (path) => {
57
- // eslint-disable-next-line @typescript-eslint/no-empty-function
58
- const noop = () => { };
59
- return new Proxy(noop, {
60
- get(target, p) {
61
- if (p === SSRStubKey) {
62
- return true;
63
- }
64
- return createProxy(path + '.' + String(p));
65
- },
66
- apply() {
67
- throw new Error(cannotInvokeMethodOnServerError(path));
68
- },
69
- });
70
- };
71
- const createStytchSSRProxy = () => createProxy('stytch');
72
36
 
73
37
  const initialMember = {
74
38
  member: null,
@@ -268,45 +232,4 @@ const StytchB2B = ({ styles, callbacks, config }) => {
268
232
  return React.createElement("div", { ref: containerEl });
269
233
  };
270
234
 
271
- /**
272
- * Creates a Headless Stytch client object to call the stytch B2B APIs.
273
- * The Stytch client is not available serverside.
274
- * @example
275
- * const stytch = createStytchB2BHeadlessClient('public-token-<find yours in the stytch dashboard>')
276
- *
277
- * return (
278
- * <StytchB2BProvider stytch={stytch}>
279
- * <App />
280
- * </StytchB2BProvider>
281
- * )
282
- * @returns A {@link StytchHeadlessClient}
283
- */
284
- const createStytchB2BHeadlessClient = (...args) => {
285
- if (typeof window === 'undefined') {
286
- return createStytchSSRProxy();
287
- }
288
- return new StytchB2BHeadlessClient(...args);
289
- };
290
-
291
- /**
292
- * Creates a Stytch UI client object to call the Stytch APIs and render Stytch UI components.
293
- * The Stytch client is not available serverside.
294
- * If you do not use Stytch UI components, use {@link createStytchB2BHeadlessClient} to reduce your bundle size.
295
- * @example
296
- * const stytch = createStytchB2BUIClient('public-token-<find yours in the stytch dashboard>')
297
- *
298
- * return (
299
- * <StytchB2BProvider stytch={stytch}>
300
- * <App />
301
- * </StytchB2BProvider>
302
- * )
303
- * @returns A {@link StytchB2BUIClient}
304
- */
305
- const createStytchB2BUIClient = (...args) => {
306
- if (typeof window === 'undefined') {
307
- return createStytchSSRProxy();
308
- }
309
- return new StytchB2BUIClient(...args);
310
- };
311
-
312
- export { StytchB2B, StytchB2BProvider, createStytchB2BHeadlessClient, createStytchB2BUIClient, useStytchB2BClient, useStytchMember, useStytchMemberSession, withStytchB2BClient, withStytchMember, withStytchMemberSession };
235
+ export { StytchB2B, StytchB2BProvider, useStytchB2BClient, useStytchMember, useStytchMemberSession, withStytchB2BClient, withStytchMember, withStytchMemberSession };
@@ -0,0 +1,16 @@
1
+ import { StytchB2BHeadlessClient } from "@stytch/vanilla-js/b2b/headless";
2
+ /**
3
+ * Creates a Headless Stytch client object to call the stytch B2B APIs.
4
+ * The Stytch client is not available serverside.
5
+ * @example
6
+ * const stytch = createStytchB2BHeadlessClient('public-token-<find yours in the stytch dashboard>')
7
+ *
8
+ * return (
9
+ * <StytchB2BProvider stytch={stytch}>
10
+ * <App />
11
+ * </StytchB2BProvider>
12
+ * )
13
+ * @returns A {@link StytchB2BHeadlessClient}
14
+ */
15
+ declare const createStytchB2BHeadlessClient: (_PUBLIC_TOKEN: string, options?: import("core/dist/public").StytchClientOptions | undefined) => StytchB2BHeadlessClient;
16
+ export { createStytchB2BHeadlessClient };
@@ -0,0 +1,16 @@
1
+ import { StytchB2BHeadlessClient } from "@stytch/vanilla-js/b2b/headless";
2
+ /**
3
+ * Creates a Headless Stytch client object to call the stytch B2B APIs.
4
+ * The Stytch client is not available serverside.
5
+ * @example
6
+ * const stytch = createStytchB2BHeadlessClient('public-token-<find yours in the stytch dashboard>')
7
+ *
8
+ * return (
9
+ * <StytchB2BProvider stytch={stytch}>
10
+ * <App />
11
+ * </StytchB2BProvider>
12
+ * )
13
+ * @returns A {@link StytchB2BHeadlessClient}
14
+ */
15
+ declare const createStytchB2BHeadlessClient: (_PUBLIC_TOKEN: string, options?: import("core/dist/public").StytchClientOptions | undefined) => StytchB2BHeadlessClient;
16
+ export { createStytchB2BHeadlessClient };