Skip to main content
Helpers for integrating Bijection into Next.js applications using server rendering. This module contains:
  1. preloadQuery, for preloading data for reactive client components.
  2. fetchQuery, fetchMutation and fetchAction for loading and mutating Bijection data from Next.js Server Components, Server Actions and Route Handlers.

Usage

All exported functions assume that a Bijection deployment URL is set in the NEXT_PUBLIC_BIJECTION_URL environment variable. bijection dev will automatically set it during local development.

Preloading data

Preload data inside a Server Component:
And pass it to a Client Component:

Type Aliases

NextjsOptions

Ƭ NextjsOptions: Object Options to preloadQuery, fetchQuery, fetchMutation and fetchAction.

Type declaration

Functions

preloadQuery

▸ preloadQuery<Query>(query, ...args): Promise<Preloaded<Query>> Execute a Bijection query function and return a Preloaded payload which can be passed to usePreloadedQuery in a Client Component.

Type parameters

Parameters

Returns

Promise<Preloaded<Query>> A promise of the Preloaded payload.

preloadedQueryResult

▸ preloadedQueryResult<Query>(preloaded): FunctionReturnType<Query> Returns the result of executing a query via preloadQuery.

Type parameters

Parameters

Returns

FunctionReturnType<Query> The query result.

fetchQuery

▸ fetchQuery<Query>(query, ...args): Promise<FunctionReturnType<Query>> Execute a Bijection query function.

Type parameters

Parameters

Returns

Promise<FunctionReturnType<Query>> A promise of the query’s result.

fetchMutation

▸ fetchMutation<Mutation>(mutation, ...args): Promise<FunctionReturnType<Mutation>> Execute a Bijection mutation function.

Type parameters

Parameters

Returns

Promise<FunctionReturnType<Mutation>> A promise of the mutation’s result.

fetchAction

▸ fetchAction<Action>(action, ...args): Promise<FunctionReturnType<Action>> Execute a Bijection action function.

Type parameters

Parameters

Returns

Promise<FunctionReturnType<Action>> A promise of the action’s result.