@trpc/next 9.14.0 → 9.15.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.
@@ -1 +1 @@
1
- {"version":3,"file":"withTRPC.d.ts","sourceRoot":"../../../src","sources":["withTRPC.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGL,uBAAuB,EAEvB,eAAe,EAEhB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,SAAS,EAAe,YAAY,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAGL,iBAAiB,EACjB,eAAe,EAChB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAuB,MAAM,aAAa,CAAC;AAI/D,aAAK,iBAAiB,GAAG,qBAAqB,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAwBtE,oBAAY,cAAc,CAAC,OAAO,SAAS,SAAS,IAClD,uBAAuB,CAAC,OAAO,CAAC,GAAG;IACjC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC,CAAC;AAEJ,wBAAgB,QAAQ,CAAC,OAAO,SAAS,SAAS,EAChD,IAAI,EAAE;IACJ,MAAM,EAAE,CAAC,IAAI,EAAE;QAAE,GAAG,CAAC,EAAE,eAAe,CAAA;KAAE,KAAK,cAAc,CAAC,OAAO,CAAC,CAAC;CACtE,GAAG,CACA;IACE,GAAG,CAAC,EAAE,KAAK,CAAC;CACb,GACD;IACE,GAAG,EAAE,IAAI,CAAC;IACV,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE;QACpB,GAAG,EAAE,eAAe,CAAC;QACrB,YAAY,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;KAC1C,KAAK,YAAY,CAAC;CACpB,CACJ,eAUkB,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAAG,iBAAiB,CAmKxE"}
1
+ {"version":3,"file":"withTRPC.d.ts","sourceRoot":"../../../src","sources":["withTRPC.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGL,uBAAuB,EAEvB,eAAe,EAEhB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,SAAS,EAAe,YAAY,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAGL,iBAAiB,EACjB,eAAe,EAChB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAuB,MAAM,aAAa,CAAC;AAI/D,aAAK,iBAAiB,GAAG,qBAAqB,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAwBtE,oBAAY,cAAc,CAAC,OAAO,SAAS,SAAS,IAClD,uBAAuB,CAAC,OAAO,CAAC,GAAG;IACjC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC,CAAC;AAEJ,wBAAgB,QAAQ,CAAC,OAAO,SAAS,SAAS,EAChD,IAAI,EAAE;IACJ,MAAM,EAAE,CAAC,IAAI,EAAE;QAAE,GAAG,CAAC,EAAE,eAAe,CAAA;KAAE,KAAK,cAAc,CAAC,OAAO,CAAC,CAAC;CACtE,GAAG,CACA;IACE,GAAG,CAAC,EAAE,KAAK,CAAC;CACb,GACD;IACE,GAAG,EAAE,IAAI,CAAC;IACV,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE;QACpB,GAAG,EAAE,eAAe,CAAC;QACrB,YAAY,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;KAC1C,KAAK,YAAY,CAAC;CACpB,CACJ,eAWkB,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAAG,iBAAiB,CAwKxE"}
@@ -57,20 +57,23 @@ function withTRPC(opts) {
57
57
  return {
58
58
  queryClient: queryClient,
59
59
  trpcClient: trpcClient,
60
- isPrepass: false
60
+ isPrepass: false,
61
+ ssrContext: null
61
62
  };
62
63
  }),
63
64
  _useState2 = _slicedToArray(_useState, 1),
64
65
  _useState2$ = _useState2[0],
65
66
  queryClient = _useState2$.queryClient,
66
67
  trpcClient = _useState2$.trpcClient,
67
- isPrepass = _useState2$.isPrepass;
68
+ isPrepass = _useState2$.isPrepass,
69
+ ssrContext = _useState2$.ssrContext;
68
70
 
69
71
  var hydratedState = trpc.useDehydratedState(trpcClient, (_props$pageProps = props.pageProps) === null || _props$pageProps === void 0 ? void 0 : _props$pageProps.trpcState);
70
72
  return /*#__PURE__*/React__default['default'].createElement(trpc.Provider, {
71
73
  client: trpcClient,
72
74
  queryClient: queryClient,
73
- isPrepass: isPrepass
75
+ isPrepass: isPrepass,
76
+ ssrContext: ssrContext
74
77
  }, /*#__PURE__*/React__default['default'].createElement(reactQuery.QueryClientProvider, {
75
78
  client: queryClient
76
79
  }, /*#__PURE__*/React__default['default'].createElement(hydration.Hydrate, {
@@ -133,7 +136,8 @@ function withTRPC(opts) {
133
136
  config: config,
134
137
  trpcClient: trpcClient,
135
138
  queryClient: queryClient,
136
- isPrepass: true
139
+ isPrepass: true,
140
+ ssrContext: ctx
137
141
  };
138
142
  prepassProps = {
139
143
  pageProps: pageProps,
@@ -57,20 +57,23 @@ function withTRPC(opts) {
57
57
  return {
58
58
  queryClient: queryClient,
59
59
  trpcClient: trpcClient,
60
- isPrepass: false
60
+ isPrepass: false,
61
+ ssrContext: null
61
62
  };
62
63
  }),
63
64
  _useState2 = _slicedToArray(_useState, 1),
64
65
  _useState2$ = _useState2[0],
65
66
  queryClient = _useState2$.queryClient,
66
67
  trpcClient = _useState2$.trpcClient,
67
- isPrepass = _useState2$.isPrepass;
68
+ isPrepass = _useState2$.isPrepass,
69
+ ssrContext = _useState2$.ssrContext;
68
70
 
69
71
  var hydratedState = trpc.useDehydratedState(trpcClient, (_props$pageProps = props.pageProps) === null || _props$pageProps === void 0 ? void 0 : _props$pageProps.trpcState);
70
72
  return /*#__PURE__*/React__default['default'].createElement(trpc.Provider, {
71
73
  client: trpcClient,
72
74
  queryClient: queryClient,
73
- isPrepass: isPrepass
75
+ isPrepass: isPrepass,
76
+ ssrContext: ssrContext
74
77
  }, /*#__PURE__*/React__default['default'].createElement(reactQuery.QueryClientProvider, {
75
78
  client: queryClient
76
79
  }, /*#__PURE__*/React__default['default'].createElement(hydration.Hydrate, {
@@ -133,7 +136,8 @@ function withTRPC(opts) {
133
136
  config: config,
134
137
  trpcClient: trpcClient,
135
138
  queryClient: queryClient,
136
- isPrepass: true
139
+ isPrepass: true,
140
+ ssrContext: ctx
137
141
  };
138
142
  prepassProps = {
139
143
  pageProps: pageProps,
@@ -47,20 +47,23 @@ function withTRPC(opts) {
47
47
  return {
48
48
  queryClient: queryClient,
49
49
  trpcClient: trpcClient,
50
- isPrepass: false
50
+ isPrepass: false,
51
+ ssrContext: null
51
52
  };
52
53
  }),
53
54
  _useState2 = _slicedToArray(_useState, 1),
54
55
  _useState2$ = _useState2[0],
55
56
  queryClient = _useState2$.queryClient,
56
57
  trpcClient = _useState2$.trpcClient,
57
- isPrepass = _useState2$.isPrepass;
58
+ isPrepass = _useState2$.isPrepass,
59
+ ssrContext = _useState2$.ssrContext;
58
60
 
59
61
  var hydratedState = trpc.useDehydratedState(trpcClient, (_props$pageProps = props.pageProps) === null || _props$pageProps === void 0 ? void 0 : _props$pageProps.trpcState);
60
62
  return /*#__PURE__*/React.createElement(trpc.Provider, {
61
63
  client: trpcClient,
62
64
  queryClient: queryClient,
63
- isPrepass: isPrepass
65
+ isPrepass: isPrepass,
66
+ ssrContext: ssrContext
64
67
  }, /*#__PURE__*/React.createElement(QueryClientProvider, {
65
68
  client: queryClient
66
69
  }, /*#__PURE__*/React.createElement(Hydrate, {
@@ -123,7 +126,8 @@ function withTRPC(opts) {
123
126
  config: config,
124
127
  trpcClient: trpcClient,
125
128
  queryClient: queryClient,
126
- isPrepass: true
129
+ isPrepass: true,
130
+ ssrContext: ctx
127
131
  };
128
132
  prepassProps = {
129
133
  pageProps: pageProps,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/next",
3
- "version": "9.14.0",
3
+ "version": "9.15.0",
4
4
  "description": "tRPC Next lib",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -30,9 +30,9 @@
30
30
  }
31
31
  },
32
32
  "peerDependencies": {
33
- "@trpc/client": "9.14.0",
34
- "@trpc/react": "9.14.0",
35
- "@trpc/server": "9.14.0",
33
+ "@trpc/client": "9.15.0",
34
+ "@trpc/react": "9.15.0",
35
+ "@trpc/server": "9.15.0",
36
36
  "next": "*",
37
37
  "react": ">=16.8.0",
38
38
  "react-dom": ">=16.8.0",
@@ -43,9 +43,9 @@
43
43
  "react-ssr-prepass": "^1.4.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@trpc/client": "9.14.0",
47
- "@trpc/react": "9.14.0",
48
- "@trpc/server": "9.14.0",
46
+ "@trpc/client": "9.15.0",
47
+ "@trpc/react": "9.15.0",
48
+ "@trpc/server": "9.15.0",
49
49
  "@types/express": "^4.17.12",
50
50
  "express": "^4.17.1",
51
51
  "next": "^12.0.1",
@@ -57,5 +57,5 @@
57
57
  "publishConfig": {
58
58
  "access": "public"
59
59
  },
60
- "gitHead": "9fc201c7e44803ff76d9ccbc06b295cf5a24c235"
60
+ "gitHead": "f7cb49f8c741e80b4af96b3fb4947eb87e73c913"
61
61
  }
package/src/withTRPC.tsx CHANGED
@@ -75,28 +75,32 @@ export function withTRPC<TRouter extends AnyRouter>(
75
75
  queryClient: QueryClient;
76
76
  trpcClient: TRPCClient<TRouter>;
77
77
  isPrepass: true;
78
+ ssrContext: NextPageContext;
78
79
  };
79
80
  return (AppOrPage: NextComponentType<any, any, any>): NextComponentType => {
80
- const trpc = createReactQueryHooks<TRouter>();
81
+ const trpc = createReactQueryHooks<TRouter, NextPageContext>();
81
82
 
82
83
  const WithTRPC = (
83
84
  props: AppPropsType & {
84
85
  trpc?: TRPCPrepassProps;
85
86
  },
86
87
  ) => {
87
- const [{ queryClient, trpcClient, isPrepass }] = useState(() => {
88
- if (props.trpc) {
89
- return props.trpc;
90
- }
91
- const config = getClientConfig({});
92
- const queryClient = new QueryClient(config.queryClientConfig);
93
- const trpcClient = trpc.createClient(config);
94
- return {
95
- queryClient,
96
- trpcClient,
97
- isPrepass: false,
98
- };
99
- });
88
+ const [{ queryClient, trpcClient, isPrepass, ssrContext }] = useState(
89
+ () => {
90
+ if (props.trpc) {
91
+ return props.trpc;
92
+ }
93
+ const config = getClientConfig({});
94
+ const queryClient = new QueryClient(config.queryClientConfig);
95
+ const trpcClient = trpc.createClient(config);
96
+ return {
97
+ queryClient,
98
+ trpcClient,
99
+ isPrepass: false,
100
+ ssrContext: null,
101
+ };
102
+ },
103
+ );
100
104
 
101
105
  const hydratedState = trpc.useDehydratedState(
102
106
  trpcClient,
@@ -108,6 +112,7 @@ export function withTRPC<TRouter extends AnyRouter>(
108
112
  client={trpcClient}
109
113
  queryClient={queryClient}
110
114
  isPrepass={isPrepass}
115
+ ssrContext={ssrContext}
111
116
  >
112
117
  <QueryClientProvider client={queryClient}>
113
118
  <Hydrate state={hydratedState}>
@@ -158,6 +163,7 @@ export function withTRPC<TRouter extends AnyRouter>(
158
163
  trpcClient,
159
164
  queryClient,
160
165
  isPrepass: true,
166
+ ssrContext: ctx,
161
167
  };
162
168
  const prepassProps = {
163
169
  pageProps,