ProofKit

Installation & Usage

This package is currently in beta. Please report any issues you find to the GitHub repository, or reach out to us in the Community

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 1a: Automated Setup with the ProofKit CLI

This automated setup expects you to have Next.js and shadcn/ui set up in your project. It will also setup various auth pages for you, but these may not work if you have a prefix configured for tailwindcss. You can use this opinionated setup to get you started, or if you need more control you should refer to the manual setup.

Run the following command to add the necessary packages and config files to your project. You will not need to follow the better-auth installation guide.

npx @proofkit/cli@beta add better-auth
pnpm dlx @proofkit/cli@beta add better-auth
yarn dlx @proofkit/cli@beta add better-auth
bunx @proofkit/cli@beta add better-auth

Step 1b: 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 package installed in your app.

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

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 { FileMakerAdapter } from "@proofkit/better-auth";

export const auth = betterAuth({
  database: FileMakerAdapter({
    odata: {
      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,
      },
      database: process.env.FM_DATABASE,
    },
  }),
  // ...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@latest migrate
pnpm dlx @proofkit/better-auth@latest migrate
yarn dlx @proofkit/better-auth@latest migrate
bunx @proofkit/better-auth@latest 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@latest migrate --username "full_access_username" --password "full_access_password"
pnpm dlx @proofkit/better-auth@latest migrate --username "full_access_username" --password "full_access_password"
yarn dlx @proofkit/better-auth@latest migrate --username "full_access_username" --password "full_access_password"
bunx @proofkit/better-auth@latest 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.