60 lines
1.7 KiB
TypeScript
60 lines
1.7 KiB
TypeScript
import { httpBatchLink } from "@trpc/client/links/httpBatchLink";
|
|
import { loggerLink } from "@trpc/client/links/loggerLink";
|
|
import { withTRPC } from "@trpc/next";
|
|
import { appWithTranslation } from "next-i18next";
|
|
import { DefaultSeo } from "next-seo";
|
|
import type { AppProps as NextAppProps } from "next/app";
|
|
|
|
import AppProviders from "@lib/app-providers";
|
|
import { seoConfig } from "@lib/config/next-seo.config";
|
|
|
|
import "../styles/globals.css";
|
|
|
|
// Workaround for https://github.com/vercel/next.js/issues/8592
|
|
export type AppProps = NextAppProps & {
|
|
/** Will be defined only is there was an error */
|
|
err?: Error;
|
|
};
|
|
|
|
function MyApp(props: AppProps) {
|
|
const { Component, pageProps, err } = props;
|
|
return (
|
|
<AppProviders {...props}>
|
|
<DefaultSeo {...seoConfig.defaultNextSeo} />
|
|
<Component {...pageProps} err={err} />
|
|
</AppProviders>
|
|
);
|
|
}
|
|
|
|
export default withTRPC({
|
|
config() {
|
|
/**
|
|
* If you want to use SSR, you need to use the server's full URL
|
|
* @link https://trpc.io/docs/ssr
|
|
*/
|
|
return {
|
|
/**
|
|
* @link https://trpc.io/docs/links
|
|
*/
|
|
links: [
|
|
// adds pretty logs to your console in development and logs errors in production
|
|
loggerLink({
|
|
enabled: (opts) =>
|
|
process.env.NODE_ENV === "development" ||
|
|
(opts.direction === "down" && opts.result instanceof Error),
|
|
}),
|
|
httpBatchLink({
|
|
url: `/api/trpc`,
|
|
}),
|
|
],
|
|
/**
|
|
* @link https://react-query.tanstack.com/reference/QueryClient
|
|
*/
|
|
// queryClientConfig: { defaultOptions: { queries: { staleTime: 6000 } } },
|
|
};
|
|
},
|
|
/**
|
|
* @link https://trpc.io/docs/ssr
|
|
*/
|
|
ssr: false,
|
|
})(appWithTranslation(MyApp));
|