Skip to main content

Module: @ts-rest/next

Classes​

Type Aliases​

InitClientArgs​

Ƭ InitClientArgs: ClientArgs & { throwOnUnknownStatus?: boolean }

Defined in​

libs/ts-rest/next/src/lib/next-client.ts:37


InitClientReturn​

Ƭ InitClientReturn<T, TClientArgs>: RecursiveProxyObj<T, TClientArgs>

Type parameters​

NameType
Textends AppRouter
TClientArgsextends ClientArgs

Defined in​

libs/ts-rest/next/src/lib/next-client.ts:32

Functions​

createNextRoute​

â–¸ createNextRoute<T>(appRouter, implementation): T extends AppRouter ? RecursiveRouterObj<T> : T extends AppRoute ? AppRouteImplementation<T> : never

Create the implementation for a given AppRouter.

Type parameters​

NameType
Textends AppRoute | AppRouter

Parameters​

NameTypeDescription
appRouterTAppRouter
implementationT extends AppRouter ? RecursiveRouterObj<T> : T extends AppRoute ? AppRouteImplementation<T> : neverImplementation of the AppRouter, e.g. your API controllers

Returns​

T extends AppRouter ? RecursiveRouterObj<T> : T extends AppRoute ? AppRouteImplementation<T> : never

Defined in​

libs/ts-rest/next/src/lib/ts-rest-next.ts:171


createNextRouter​

â–¸ createNextRouter<T>(routes, obj, options?): (req: NextApiRequest, res: NextApiResponse) => Promise<void | NextApiResponse<any>>

Turn a completed set of Next routes into a Next.js compatible route.

Should be exported from your [...ts-rest].tsx file.

e.g.

export default createNextRouter(contract, implementation);

Type parameters​

NameType
Textends AppRouter

Parameters​

NameType
routesT
objRecursiveRouterObj<T>
options?CreateNextRouterOptions

Returns​

fn

â–¸ (req, res): Promise<void | NextApiResponse<any>>

Parameters​
NameType
reqNextApiRequest
resNextApiResponse
Returns​

Promise<void | NextApiResponse<any>>

Defined in​

libs/ts-rest/next/src/lib/ts-rest-next.ts:196


createSingleRouteHandler​

â–¸ createSingleRouteHandler<T>(appRoute, implementationHandler, options?): (req: NextApiRequest, res: NextApiResponse) => Promise<void | NextApiResponse<any>>

Turn a contract route and a handler into a Next.js compatible handler Should be exported from your pages/api/path/to/handler.tsx file.

e.g.

export default createNextRouter(contract, implementationHandler);

Type parameters​

NameType
Textends AppRoute

Parameters​

NameType
appRouteAppRoute
implementationHandlerAppRouteImplementation<T>
options?CreateNextRouterOptions

Returns​

fn

â–¸ (req, res): Promise<void | NextApiResponse<any>>

Parameters​
NameType
reqNextApiRequest
resNextApiResponse
Returns​

Promise<void | NextApiResponse<any>>

Defined in​

libs/ts-rest/next/src/lib/ts-rest-next.ts:237


initNextClient​

â–¸ initNextClient<T, TClientArgs>(router, args): RecursiveProxyObj<T, TClientArgs>

Type parameters​

NameType
Textends AppRouter
TClientArgsextends InitClientArgs

Parameters​

NameType
routerT
argsTClientArgs

Returns​

RecursiveProxyObj<T, TClientArgs>

Deprecated

use initClient from @ts-rest/core instead

Defined in​

libs/ts-rest/next/src/lib/next-client.ts:48


isAppRouteWithImplementation​

â–¸ isAppRouteWithImplementation(obj): obj is any

Parameters​

NameType
objany

Returns​

obj is any

Defined in​

libs/ts-rest/next/src/lib/ts-rest-next.ts:92