@olgax.com/datasource
API reference for @olgax.com/datasource - collectionQueryFields, createCollectionResolverFetch, createCollectionResolver and queryCollectionFromSearchParams.
A narrow resolver layer for feeding Payload collection data into Puck components.
pnpm add @olgax.com/datasourceSee Data sources for a walkthrough.
CollectionQueryProps
type CollectionQueryProps = {
collection: string;
filterField?: string;
filterValue?: string;
limit?: number;
items?: unknown[];
};One collection, a single equality filter and a limit (default 10). No operators and no and or or.
collectionQueryFields
Puck field definitions for collection, filterField, filterValue (text) and limit (number). Spread them into a
component's fields.
createCollectionResolverFetch
createCollectionResolverFetch<Props extends CollectionQueryProps>(endpoint: string): ResolveDataReturns a Puck resolveData that calls a same-app route handler with fetch(). It never imports payload, so it is
safe in a config shared by the client-side editor and server-side rendering. On the server it uses
NEXT_PUBLIC_SITE_URL (default http://localhost:3000) as the base URL.
It re-runs only when collection, filterField, filterValue or limit changes, and writes the result to a
read-only items prop.
queryCollectionFromSearchParams
queryCollectionFromSearchParams(
getPayload: () => Promise<Payload>,
searchParams: URLSearchParams,
): Promise<unknown[]>The server-side half. Use it in the route handler that createCollectionResolverFetch calls. Returns an empty array when
no collection is given.
createCollectionResolver
createCollectionResolver<Props extends CollectionQueryProps>(getPayload: () => Promise<Payload>): ResolveDataRuns the Payload Local API find() directly. Server only. Use it only in a config that backs server-rendered output
and never reaches the client <Puck> editor, otherwise payload ends up in the browser bundle.
Questions, ideas or something not working?
Ask in our official Discord, open an issue on GitHub, or edit this page.
@olgax.com/components
The default Olgax DXP component library - Hero, Header, Footer, CTA, Gallery, Pricing, FAQ, Testimonials and RelatedPages - with props and theming.
@olgax.com/payload-preset
Reference for @olgax.com/payload-preset - the Payload CMS collections and globals behind Olgax DXP - users, media, pages, sections, page views, webhooks and site settings.