basefyio + Express: Backend Data Access in Node.js APIs

Running an Express API? Use basefyio-js server-side to read and write database access, with a service key for trusted operations that bypass row-level security.

Install

npm install basefyio-js

Create 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
});

Keep the service key on the server only. Use it for trusted operations; for anything reachable by the browser, use the anon key with row-level security.

Use it in a route handler

import express from "express";
import { bf } from "./basefyio.js";

const app = express();

app.get("/api/posts", async (_req, res) => {
  const { data, error } = await bf.from("posts").select("id, title");
  if (error) return res.status(500).json({ error });
  res.json(data);
});

app.listen(3000);

Trusted server access

Use a service key for operations that need to bypass row-level security.

Add a custom API surface

Expose your own endpoints with Express while basefyio handles the data layer.

Raw SQL available

Use bf.sql for reports and complex queries beyond the query builder.

Frequently asked questions

Can I build a custom REST API over basefyio with Express?
Yes. Use Express for bespoke endpoints and business logic, and basefyio-js with a service key for data access.
Should I use the anon or service key in Express?
Use the service key for trusted server operations. If you forward requests on behalf of end users, prefer the anon key so row-level security still applies.

Other integrations

Build your Express backend on basefyio

database, auth, storage, and a REST API — running in minutes.

Get started