basefyio + SvelteKit: Backend for Svelte Apps

SvelteKit covers routing and rendering; basefyio covers the backend. Use basefyio-js in load functions and server endpoints to fetch and mutate data.

Install

npm install basefyio-js

Create the client

// src/lib/basefyio.ts
import { createClient } from "basefyio-js";
import { PUBLIC_BASEFYIO_PROJECT_ID, PUBLIC_BASEFYIO_ANON_KEY } from "$env/static/public";

export const bf =createClient({
  projectId: PUBLIC_BASEFYIO_PROJECT_ID,
  apiKey: PUBLIC_BASEFYIO_ANON_KEY,
});

Use PUBLIC_ env variables with the anon key for client/load code. Keep service keys in private env variables for server-only logic.

Load data for a route

// src/routes/posts/+page.ts
import { bf } from "$lib/basefyio";

export async function load() {
  const { data } = await bf.from("posts").select("id, title");
  return { posts: data ?? [] };
}

Works in load functions

Fetch data during SSR or on the client with the same SDK call.

No backend boilerplate

Skip writing endpoints for basic data access — query the database directly.

Auth and storage included

bf.auth and bf.storage cover sign-in and file uploads out of the box.

Frequently asked questions

Can I use basefyio in SvelteKit server endpoints?
Yes. Create a server-side client with a service key in +server.ts or +page.server.ts for trusted operations, and a public client for the browser.
Does row-level security still apply?
Yes. With the anon key, every query is constrained by your row-level security policies.

Other integrations

Build your SvelteKit backend on basefyio

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

Get started