Use a typed data client
The Agentic Development Kit (ADK) provides type-safe access to FileMaker records through a client generated by Typegen. Each app binds to one connected file, and its client communicates exclusively with that file.
The @adk/fmdapi library
The client uses @adk/fmdapi, a library bundling the Data API client, Web Viewer adapter, and agent skill. It is vendored into your project at vendor/@adk/fmdapi during initial app creation rather than installed from npm. Apps resolve it through the pnpm workspace.
To update the vendored library after an ADK release, prompt your coding agent to update it. See Agentic Development Kit updates.
@adk/fmdapi exports DataApi, WebViewerAdapter, fmFetch, callFMScript, and React helpers. Typegen wires the layout, schema, and adapter into the generated client. See Generate types with Typegen.
Use the generated client
Import generated types and clients directly:
import type { TContacts } from "@/config/schemas/filemaker/Contacts";
import { ContactsLayout } from "@/config/schemas/filemaker/client";
const response = await ContactsLayout.find({
query: { Status: "Active" },
limit: 25,
});
const firstContact: TContacts | undefined = response.data[0]?.fieldData;
find(), get(), and list() return data as an array of { fieldData, recordId, modId }, even when fetching a single record by ID. Use findOne, findFirst, or maybeFindFirst to return a single record directly.
By default, a find with no matches throws FileMaker error 401. Pass ignoreEmptyResult: true when an empty result is an expected outcome:
const response = await ContactsLayout.find({
query: { Status: "Archived" },
ignoreEmptyResult: true,
});
// response.data is [] when nothing matches
Update records using the same client:
await ContactsLayout.update({
recordId: 42,
fieldData: { Status: "Inactive" },
});
Load data with TanStack Query
Use TanStack Query, included in the project template, to manage caching and automatic refetching after mutations or script executions:
import { ContactsLayout } from "@/config/schemas/filemaker/client";
import { useQuery } from "@tanstack/react-query";
export function useContactsPage(page: number) {
return useQuery({
queryKey: ["contacts", { page }],
queryFn: () =>
ContactsLayout.find({ query: { Status: "Active" }, limit: 25, offset: page * 25 + 1 }),
});
}
Use FileMaker scripts for transactions
Data API calls are not transactional. When multiple records must update together or record locking is critical, call a FileMaker script. See Splitting app logic.
import { fmFetch } from "@adk/fmdapi";
await fmFetch("Deactivate Contact And Related Orders", { contactId: 42 });
Common mistakes
-
Expecting a single record from
get():get()returns an array inresponse.data. Access the first record withresponse.data[0]?.fieldData, or usefindFirstormaybeFindFirst. -
Failing to handle empty finds: Unhandled empty finds throw FileMaker error 401. Set
ignoreEmptyResult: truewhen zero matches is acceptable. -
Bypassing the generated client: Manually configuring a
DataApiclient removes the type safety provided by Typegen. -
Redefining types manually: Import
T<Schema>to prevent types from drifting from FileMaker layouts. -
Querying unbounded datasets: Methods like
listAllandfindAllcan load excessive records. Use paginatedfindorlistcalls with explicitlimitandoffsetparameters.
Related topics
-
Generate types with Typegen—Configure layouts and regenerate client files.
-
Build and deploy an app—Bundle and deploy your web app into FileMaker.
-
FileMaker Data API client—Complete client API reference.
-
adk.config.json—Typegen configuration options.