@stytch/nextjs 1.2.0 → 2.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,16 @@
1
1
  # @stytch/nextjs
2
2
 
3
+ ## 2.0.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Launching B2B SDKs
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @stytch/vanilla-js@0.10.0
13
+
3
14
  ## 1.2.0
4
15
 
5
16
  ### Patch Changes
@@ -0,0 +1,119 @@
1
+ /// <reference types="react" />
2
+ import React from "react";
3
+ import { ReactNode } from "react";
4
+ import { StytchB2BHeadlessClient, Member, MemberSession } from "@stytch/vanilla-js/b2b/";
5
+ import { StytchB2BHeadlessClient as StytchB2BHeadlessClient$0 } from "@stytch/vanilla-js/b2b";
6
+ /**
7
+ * The Stytch Client object passed in to <StytchProvider /> in your `_app.js`.
8
+ * Either a StytchUIClient or StytchHeadlessClient.
9
+ */
10
+ type StytchB2BClient = StytchB2BHeadlessClient;
11
+ type SWRMember = {
12
+ member: null;
13
+ fromCache: false;
14
+ isInitialized: false;
15
+ } | {
16
+ member: Member | null;
17
+ fromCache: boolean;
18
+ isInitialized: true;
19
+ };
20
+ type SWRMemberSession = {
21
+ session: null;
22
+ fromCache: false;
23
+ isInitialized: false;
24
+ } | {
25
+ session: MemberSession | null;
26
+ fromCache: boolean;
27
+ isInitialized: true;
28
+ };
29
+ /**
30
+ * Returns the active member.
31
+ * The Stytch SDKs are used for client-side authentication and session management.
32
+ * 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.
35
+ * @example
36
+ * const {member, isInitialized, fromCache} = useStytchMember();
37
+ * if (!isInitialized) {
38
+ * return <p>Loading...</p>;
39
+ * }
40
+ * return (<h1>Welcome, {member.name}</h1>);
41
+ */
42
+ declare const useStytchMember: () => SWRMember;
43
+ /**
44
+ * Returns the member's active Stytch member session.
45
+ * The Stytch SDKs are used for client-side authentication and session management.
46
+ * Check the isInitialized property to determine if the SDK has completed initialization.
47
+ * 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
+ * @example
50
+ * const {session, isInitialized, fromCache} = useStytchMemberSession();
51
+ * useEffect(() => {
52
+ * if (!isInitialized) {
53
+ * return;
54
+ * }
55
+ * if (!session) {
56
+ * router.replace('/login')
57
+ * }
58
+ * }, [session, isInitialized]);
59
+ */
60
+ declare const useStytchMemberSession: () => SWRMemberSession;
61
+ /**
62
+ * Returns the Stytch client stored in the Stytch context.
63
+ *
64
+ * @example
65
+ * const stytch = useStytch();
66
+ * useEffect(() => {
67
+ * stytch.magicLinks.authenticate('...')
68
+ * }, [stytch]);
69
+ */
70
+ declare const useStytchB2BClient: () => StytchB2BClient;
71
+ declare const withStytchB2BClient: <T extends object>(Component: React.ComponentType<T & {
72
+ stytch: StytchB2BClient;
73
+ }>) => React.ComponentType<T>;
74
+ declare const withStytchMember: <T extends object>(Component: React.ComponentType<T & {
75
+ stytchMember: Member | null;
76
+ stytchMemberIsInitialized: boolean;
77
+ stytchMemberIsFromCache: boolean;
78
+ }>) => React.ComponentType<T>;
79
+ declare const withStytchMemberSession: <T extends object>(Component: React.ComponentType<T & {
80
+ stytchMemberSession: MemberSession | null;
81
+ stytchMemberSessionIsInitialized: boolean;
82
+ stytchMemberSessionIsFromCache: boolean;
83
+ }>) => React.ComponentType<T>;
84
+ interface StytchB2BProviderProps {
85
+ /**
86
+ * A Stytch client instance, created using either {@link createStytchHeadlessClient} or {@link createStytchUIClient}
87
+ */
88
+ stytch: StytchB2BClient;
89
+ children?: ReactNode;
90
+ }
91
+ /**
92
+ * The Stytch Context Provider.
93
+ * Wrap your application with this component in `_app.js` in order to use Stytch everywhere in your app.
94
+ * @example
95
+ * const stytch = createStytchB2BHeadlessClient('public-token-<find yours in the stytch dashboard>')
96
+ *
97
+ * return (
98
+ * <StytchB2BProvider stytch={stytch}>
99
+ * <App />
100
+ * </StytchB2BProvider>
101
+ * )
102
+ */
103
+ declare const StytchB2BProvider: ({ stytch, children }: StytchB2BProviderProps) => JSX.Element;
104
+ /**
105
+ * Creates a Headless Stytch client object to call the stytch B2B APIs.
106
+ * The Stytch client is not available serverside.
107
+ * @example
108
+ * const stytch = createStytchB2BHeadlessClient('public-token-<find yours in the stytch dashboard>')
109
+ *
110
+ * return (
111
+ * <StytchB2BProvider stytch={stytch}>
112
+ * <App />
113
+ * </StytchB2BProvider>
114
+ * )
115
+ * @returns A {@link StytchHeadlessClient}
116
+ */
117
+ declare const createStytchB2BHeadlessClient: (_PUBLIC_TOKEN: string, options?: import("core/dist/public").StytchClientOptions | undefined) => StytchB2BHeadlessClient$0;
118
+ export { StytchB2BProvider, useStytchB2BClient, useStytchMemberSession, useStytchMember, withStytchB2BClient, withStytchMemberSession, withStytchMember, createStytchB2BHeadlessClient };
119
+ export type { StytchB2BProviderProps };
@@ -0,0 +1,119 @@
1
+ /// <reference types="react" />
2
+ import React from "react";
3
+ import { ReactNode } from "react";
4
+ import { StytchB2BHeadlessClient, Member, MemberSession } from "@stytch/vanilla-js/b2b/";
5
+ import { StytchB2BHeadlessClient as StytchB2BHeadlessClient$0 } from "@stytch/vanilla-js/b2b";
6
+ /**
7
+ * The Stytch Client object passed in to <StytchProvider /> in your `_app.js`.
8
+ * Either a StytchUIClient or StytchHeadlessClient.
9
+ */
10
+ type StytchB2BClient = StytchB2BHeadlessClient;
11
+ type SWRMember = {
12
+ member: null;
13
+ fromCache: false;
14
+ isInitialized: false;
15
+ } | {
16
+ member: Member | null;
17
+ fromCache: boolean;
18
+ isInitialized: true;
19
+ };
20
+ type SWRMemberSession = {
21
+ session: null;
22
+ fromCache: false;
23
+ isInitialized: false;
24
+ } | {
25
+ session: MemberSession | null;
26
+ fromCache: boolean;
27
+ isInitialized: true;
28
+ };
29
+ /**
30
+ * Returns the active member.
31
+ * The Stytch SDKs are used for client-side authentication and session management.
32
+ * 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.
35
+ * @example
36
+ * const {member, isInitialized, fromCache} = useStytchMember();
37
+ * if (!isInitialized) {
38
+ * return <p>Loading...</p>;
39
+ * }
40
+ * return (<h1>Welcome, {member.name}</h1>);
41
+ */
42
+ declare const useStytchMember: () => SWRMember;
43
+ /**
44
+ * Returns the member's active Stytch member session.
45
+ * The Stytch SDKs are used for client-side authentication and session management.
46
+ * Check the isInitialized property to determine if the SDK has completed initialization.
47
+ * 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
+ * @example
50
+ * const {session, isInitialized, fromCache} = useStytchMemberSession();
51
+ * useEffect(() => {
52
+ * if (!isInitialized) {
53
+ * return;
54
+ * }
55
+ * if (!session) {
56
+ * router.replace('/login')
57
+ * }
58
+ * }, [session, isInitialized]);
59
+ */
60
+ declare const useStytchMemberSession: () => SWRMemberSession;
61
+ /**
62
+ * Returns the Stytch client stored in the Stytch context.
63
+ *
64
+ * @example
65
+ * const stytch = useStytch();
66
+ * useEffect(() => {
67
+ * stytch.magicLinks.authenticate('...')
68
+ * }, [stytch]);
69
+ */
70
+ declare const useStytchB2BClient: () => StytchB2BClient;
71
+ declare const withStytchB2BClient: <T extends object>(Component: React.ComponentType<T & {
72
+ stytch: StytchB2BClient;
73
+ }>) => React.ComponentType<T>;
74
+ declare const withStytchMember: <T extends object>(Component: React.ComponentType<T & {
75
+ stytchMember: Member | null;
76
+ stytchMemberIsInitialized: boolean;
77
+ stytchMemberIsFromCache: boolean;
78
+ }>) => React.ComponentType<T>;
79
+ declare const withStytchMemberSession: <T extends object>(Component: React.ComponentType<T & {
80
+ stytchMemberSession: MemberSession | null;
81
+ stytchMemberSessionIsInitialized: boolean;
82
+ stytchMemberSessionIsFromCache: boolean;
83
+ }>) => React.ComponentType<T>;
84
+ interface StytchB2BProviderProps {
85
+ /**
86
+ * A Stytch client instance, created using either {@link createStytchHeadlessClient} or {@link createStytchUIClient}
87
+ */
88
+ stytch: StytchB2BClient;
89
+ children?: ReactNode;
90
+ }
91
+ /**
92
+ * The Stytch Context Provider.
93
+ * Wrap your application with this component in `_app.js` in order to use Stytch everywhere in your app.
94
+ * @example
95
+ * const stytch = createStytchB2BHeadlessClient('public-token-<find yours in the stytch dashboard>')
96
+ *
97
+ * return (
98
+ * <StytchB2BProvider stytch={stytch}>
99
+ * <App />
100
+ * </StytchB2BProvider>
101
+ * )
102
+ */
103
+ declare const StytchB2BProvider: ({ stytch, children }: StytchB2BProviderProps) => JSX.Element;
104
+ /**
105
+ * Creates a Headless Stytch client object to call the stytch B2B APIs.
106
+ * The Stytch client is not available serverside.
107
+ * @example
108
+ * const stytch = createStytchB2BHeadlessClient('public-token-<find yours in the stytch dashboard>')
109
+ *
110
+ * return (
111
+ * <StytchB2BProvider stytch={stytch}>
112
+ * <App />
113
+ * </StytchB2BProvider>
114
+ * )
115
+ * @returns A {@link StytchHeadlessClient}
116
+ */
117
+ declare const createStytchB2BHeadlessClient: (_PUBLIC_TOKEN: string, options?: import("core/dist/public").StytchClientOptions | undefined) => StytchB2BHeadlessClient$0;
118
+ export { StytchB2BProvider, useStytchB2BClient, useStytchMemberSession, useStytchMember, withStytchB2BClient, withStytchMemberSession, withStytchMember, createStytchB2BHeadlessClient };
119
+ export type { StytchB2BProviderProps };