Skip to content

Creating a Client

The client is how you enqueue jobs from your application code. It’s fully typed — each job in the router becomes a property with an .enqueue() method whose input type is inferred from the Zod schema.

import { createClient } from "@queuebase/nextjs"; // or @queuebase/node
import { jobs } from "./jobs";
export const jobClient = createClient(jobs, {
apiUrl: "http://localhost:3847",
callbackUrl: "http://localhost:3000/api/queuebase",
apiKey: undefined, // required in production
});
ParameterTypeDescription
apiUrlstringQueuebase API URL. In dev: http://localhost:3847
callbackUrlstringYour app’s webhook endpoint (e.g. http://localhost:3000/api/queuebase)
apiKeystring | undefinedAPI key for authenticating with the Queuebase API. Required in production.

In practice, pull these from environment variables:

export const jobClient = createClient(jobs, {
apiUrl: process.env.QUEUEBASE_API_URL ?? "http://localhost:3847",
apiKey: process.env.QUEUEBASE_API_KEY,
callbackUrl:
process.env.QUEUEBASE_CALLBACK_URL ??
"http://localhost:3000/api/queuebase",
});

See Configuration for the full list of environment variables.