Early Preview: 🚧 These docs are still a work in progress. 🚧 Keep checking back for updates!
ProofKit

Installation & Usage

Prerequisites

  • Ensure OData is enabled on your FileMaker server.
  • Ensure your credentials have the fmodata privilege enabled.
  • If you are using OttoFMS 4.11+ and you want to use a Data API key instead of plain credentials, ensure OData is enabled for that key.

Step 1: Manual Setup

Follow the Better-Auth installation guide to get started in your app, but come back here for special instructions for anything related to your Database Setup or schema migrations.

Database Setup

Ensure you have the @proofkit/better-auth and @proofkit/fmodata packages installed in your app.

npm install @proofkit/better-auth @proofkit/fmodata
pnpm add @proofkit/better-auth @proofkit/fmodata
yarn add @proofkit/better-auth @proofkit/fmodata
bun add @proofkit/better-auth @proofkit/fmodata

Configure your database connection in your auth.ts file. Be sure to set these value secrets in your environment variables. The credentials you use here need fmodata permissions enabled, and read/write access to the better-auth tables.

auth.ts
import { betterAuth } from "better-auth";
import { FMServerConnection } from "@proofkit/fmodata";
import { FileMakerAdapter } from "@proofkit/better-auth";

const connection = new FMServerConnection({
  serverUrl: process.env.FM_SERVER_URL!,
  auth: {
    // option 1: username/password credentials
    username: process.env.FM_USERNAME!,
    password: process.env.FM_PASSWORD!,

    // option 2: Data API key (OttoFMS 4.11+, OData enabled for the key)
    // apiKey: process.env.OTTO_API_KEY!,
  },
});

const db = connection.database(process.env.FM_DATABASE!);

export const auth = betterAuth({
  database: FileMakerAdapter({ database: db }),
  // ...rest of your config
});

Step 2: Create/Update Database Tables

Run the following command to create the necessary tables and fields in your FileMaker file. It will show you a confirmation before any changes are applied, so you can review them.

npx @proofkit/better-auth migrate
pnpm dlx @proofkit/better-auth migrate
yarn dlx @proofkit/better-auth migrate
bunx @proofkit/better-auth migrate

[Full Access] credentials are required for the schema changes to be applied automatically, but you may want to use a more restricted account for the rest of better-auth usage. If your credentials that you entered earlier in the auth.ts file do not have the [Full Access] permissions, you can override them in the CLI.

npx @proofkit/better-auth migrate --username "full_access_username" --password "full_access_password"
pnpm dlx @proofkit/better-auth migrate --username "full_access_username" --password "full_access_password"
yarn dlx @proofkit/better-auth migrate --username "full_access_username" --password "full_access_password"
bunx @proofkit/better-auth migrate --username "full_access_username" --password "full_access_password"

These changes affect database schema only. No layouts or relationships are created or modified during this process.

The tables/fields that are created will be dependent on how your auth.ts file is setup. If you want to use any of your existing tables, just set custom table names in the auth.ts file before running the migration command.

You may see fields added to your tables that you don't plan on using, but it's best to keep them in your database anyway to avoid potential errors.

If you make any schema-related changes to the better-auth config, such as adding plugins, you will need to run the migration command again to apply the changes to your FileMaker file.

On this page