basefyio + Node.js: Backend Data Access from the Server
From Node.js you can run trusted server-side logic against basefyio — background jobs, webhooks, scripts, and APIs — using a service key for full access.
Install
npm install basefyio-jsCreate a server client
// basefyio.js
import { createClient } from "basefyio-js";
export const bf =createClient({
projectId: process.env.BASEFYIO_PROJECT_ID,
apiKey: process.env.BASEFYIO_SERVICE_KEY, // server-only
});On the server you can use a service key for trusted operations that bypass row-level security. Never expose a service key to the browser.
Run a query or raw SQL
import { bf } from "./basefyio.js";
// Query builder
const { data } = await bf.from("users").select("id, email").eq("active", true);
// Or raw SQL for reports (sanitize any dynamic input!)
const { data: stats } = await bf.sql(
"select plan, count(*) from subscriptions group by plan",
);Trusted server access
Use a service key for jobs and admin tasks that need to bypass row-level security.
Raw SQL when you need it
Run reports and complex queries with bf.sql, in addition to the query builder.
Same SDK everywhere
Share data-access code between your server and client where appropriate.
Frequently asked questions
- Can I run background jobs against basefyio?
- Yes. Use a Node.js process with a service key to run scheduled jobs, process webhooks, or perform admin operations.
- When should I use a service key vs. the anon key?
- Use the service key only on trusted servers for operations that must bypass row-level security. Use the anon key for anything reachable by the browser.
Other integrations
Build your Node.js backend on basefyio
database, auth, storage, and a REST API — running in minutes.