Skip to main content
You can use FrogBot’s Local API outside Next.js for seed scripts, one-off maintenance tasks, or backend services in other frameworks.
FrogBot and all of its official packages are fully ESM. If you want to use FrogBot within your own projects, make sure you are writing your scripts in ESM format or dynamically importing the FrogBot Config.

Run a standalone script

In your FrogBot app, create src/seed.ts. Import your config through the app’s @frogbot-config alias and initialize FrogBot with getFrogBot. Its options are listed in Importing it. This example creates a user in the users collection included in a fresh app:
Run the script from your app’s root directory:
The frogbot run <file> [args...] command:
  1. Loads .env* files from the current directory using Next.js environment-loading rules before importing your script. You don’t need dotenv. With NODE_ENV unset, it uses development environment files; set NODE_ENV=production to use production environment files.
  2. Resolves the file relative to the current directory and runs TypeScript or JavaScript through tsx, including your app’s @frogbot-config alias.
  3. Passes every argument after the file unchanged to your script in process.argv.slice(2). process.argv[1] is the absolute script path.
  4. Destroys the cached FrogBot instance and exits with code 0 when your script’s top level finishes. Await all work you need to complete, as in await seed() above; pending timers or background work won’t keep the command running.
If the script or cleanup throws, FrogBot prints [frogbot] run failed: <file> and the error stack, then exits with code 1. A missing file prints a file-not-found message and exits with code 1. Omitting the file prints usage and exits with code 2.