fmBridge()

fmBridge() is the Vite plugin that lets you develop a Web Viewer app in a browser instead of inside FileMaker's Web Viewer. With it running, code that calls window.FileMaker or uses @adk/fmdapi works the same in pnpm dev as it does after you deploy: no rebuild, no re-upload, no mock data.

Why it matters

A Web Viewer app expects to live inside FileMaker. Outside of FileMaker, window.FileMaker does not exist and script calls fail. Without a bridge, testing requires building, deploying, and reopening the file after each code change.

fmBridge() removes that loop by forwarding window.FileMaker calls from the development browser to your open FileMaker file. A deployed Web Viewer does not use it because FileMaker provides window.FileMaker directly.

Apps created by adk app add configure this automatically in vite.config.ts.

How it works

fmBridge() queries FileMaker Pro for open files using built-in Agent Access on port 19080 (or the custom port set by FM_DEV_SERVER_PORT). It resolves the target file dynamically on every call:

  1. Your development page calls window.FileMaker.PerformScriptAsync (or a @adk/fmdapi function wrapping it).

  2. fmBridge() supplies that function during vite dev, forwarding the call same-origin to the Vite dev server at /__fm/fmfetch.

  3. The dev server queries FileMaker Pro for open files and selects the target file (either the single open file or the file configured in fileName).

  4. The dev server executes the script in that file over Agent Access and returns the Exit Script result to the page.

Setup

Copy
import { fmBridge } from "@adk/fmdapi/vite";
import { defineConfig } from "vite";

export default defineConfig({
  plugins: [fmBridge()],
});

fmBridge() activates exclusively during vite dev. In production builds, it is completely inactive.

Options:

  • fileName—Specifies which open FileMaker file to use when multiple databases are open concurrently. With a single open file, fmBridge() resolves it automatically.

Developing in a real browser

To use the bridge during local browser development:

  1. Open your FileMaker file in FileMaker Pro 26.1.2 or later with Agent Access on: See System requirements.

    With a stored keychain password for the file, ADK signs in and FileMaker Pro shows no dialog. If an authorization dialog appears, enter your credentials or click Allow. Access lasts until you revoke it, the file closes, or you quit FileMaker Pro.

  2. Start your dev server:

    Copy
    pnpm dev
  3. Open the local dev server URL: Open http://localhost:5175 in your browser. Calls to window.FileMaker route through the bridge to the live file.

When no file is open, the dev server still starts and injects a stub window.FileMaker whose methods reject with an explicit message explaining that FileMaker Pro does not have the file open.

When the file is closed or the prompt is waiting

If FileMaker Pro quits, restarts, or the file closes, script calls fail because fmBridge() re-resolves the file on each call. Reopen the file in FileMaker Pro and reload the browser page.

If script calls hang after restarting FileMaker Pro, check if an authorization dialog is waiting behind another window. See Components and Web Viewer connection problems.