@trpc/next
Version:
32 lines • 1.49 kB
text/typescript
import { TransformerOptions } from "@trpc/client/unstable-internals";
import { AnyRouter, inferClientTypes, inferRouterContext } from "@trpc/server/unstable-core-do-not-import";
import { TRPCLink } from "@trpc/client";
export type NextCacheLinkOptions<TRouter extends AnyRouter> = {
/**
* The router to call.
*/
router: TRouter;
/**
* Creates the context for each call. A cached result was made with the
* context of whichever request ran it first.
*/
createContext: () => Promise<inferRouterContext<TRouter>>;
/** how many seconds the cache should hold before revalidating */
revalidate?: number | false;
} & TransformerOptions<inferClientTypes<TRouter>>;
/**
* A terminating link that calls the router directly and caches query
* results with Next.js `unstable_cache`.
*
* The cache is shared by every request. A query is cached by its path and
* input only, not its context, and a cached result is returned without
* running the procedure or its middleware. So don't send queries whose
* result depends on the context, such as the current user's data or an
* auth check, through this link: one user's result would be served to
* everyone. Route those to an uncached link such as `localLink` with
* `splitLink`.
*
* @see https://trpc.io/docs/client/nextjs/app-router-setup
*/
export declare function experimental_nextCacheLink<TRouter extends AnyRouter>(opts: NextCacheLinkOptions<TRouter>): TRPCLink<TRouter>;
//# sourceMappingURL=nextCache.d.mts.map