Skip to main content

Module: @ts-rest/next

Type Aliases

InitClientArgs

Ƭ InitClientArgs: ClientArgs & { throwOnUnknownStatus?: boolean }

Defined in

lib/next-client.ts:29


InitClientReturn

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

Type parameters

NameType
Textends AppRouter
TClientArgsextends ClientArgs

Defined in

lib/next-client.ts:24

Functions

createNextRoute

createNextRoute<T>(appRouter, implementation): RecursiveRouterObj<T>

Create the implementation for a given AppRouter.

Type parameters

NameType
Textends AppRouter

Parameters

NameTypeDescription
appRouterTAppRouter
implementationRecursiveRouterObj<T>Implementation of the AppRouter, e.g. your API controllers

Returns

RecursiveRouterObj<T>

Defined in

lib/ts-rest-next.ts:153


createNextRouter

createNextRouter<T>(routes, obj, options?): (req: NextApiRequest, res: NextApiResponse) => Promise<void>

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?Object
options.errorHandler?(err: unknown, req: NextApiRequest, res: NextApiResponse) => void
options.jsonQuery?boolean
options.responseValidation?boolean

Returns

fn

▸ (req, res): Promise<void>

Parameters
NameType
reqNextApiRequest
resNextApiResponse
Returns

Promise<void>

Defined in

lib/ts-rest-next.ts:174


initNextClient

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

Type parameters

NameType
Textends AppRouter
TClientArgsextends InitClientArgs

Parameters

NameType
routerT
argsTClientArgs

Returns

RecursiveProxyObj<T, TClientArgs>

Defined in

lib/next-client.ts:37


isAppRouteWithImplementation

isAppRouteWithImplementation(obj): obj is any

Parameters

NameType
objany

Returns

obj is any

Defined in

lib/ts-rest-next.ts:74