jsclient

package
v0.9.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: MIT, MIT Imports: 1 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

backd-js

JavaScript client for backd: sign-up, login and sessions, collections with access rules, and the admin API. Plain ES modules with TypeScript declarations, no dependencies, no build step. Runs in browsers, Node 20+, Deno, Bun and edge runtimes.

npm install backd-js
import { createClient, localStorageStorage } from 'backd-js'

const backd = createClient({ url: 'https://localhost:8443', realm: 'blog', storage: localStorageStorage() })

await backd.auth.signup({ email: 'ada@example.com', password: 'dev-p4ssw0rd!' })

const posts = backd.db('main').collection('posts')
await posts.create({ title: 'Hello', published: true })
const page = await posts.list({ where: { published: true }, orderBy: '-_meta.created_at', limit: 20 })

Server-side code can use an API key (never in browsers) for full access and the admin API:

const admin = createClient({ url, realm: 'blog', apiKey: process.env.BACKD_API_KEY }).admin
const user = await admin.users.find('ada@example.com')

Versions

backd-js is released on the same version as the backd server (backd-js 0.9.9 goes with backd v0.9.9). The upgrade notes say what each release changed.

Types

backd types generates types.d.ts from the realm's config, and the client takes it as a type:

import { createClient } from 'backd-js'
import type { Realm } from './backd/types'

const backd = createClient<Realm>({ url, realm: 'blog' })
backd.db('main').collection('posts').list({ where: { published: true } })   // fields and operators checked

Examples

examples/blog is a small blog built with Alpine.js: sign up, log in, write, publish and delete posts. examples/expenses-without-functions shares expenses between users, and shows the limits of access rules. From the repository root:

make example          # from the repository root; then open https://localhost:8443/example/

nginx serves the examples, the API and the docs on one origin, so the examples need no CORS settings. They import backd-js through an import map.

Documentation

The full guide (options, auth events, token storage, collections, concurrent edits, errors, retries, admin API) is in the backd docs, under Clients → JavaScript client (docs/content/docs/clients/js.md).

Development

npm install              # also builds the type declarations into types/
npm run typecheck        # tsc --checkJs, strict
npm test                 # unit tests (node:test, mocked fetch)
make js-integration      # from the repository root: tests against backd + MongoDB in Docker

Documentation

Overview

Package jsclient embeds the JavaScript client's sources, so the functions runner can give each function a real client as ctx.db. The client itself is plain ESM JavaScript with no dependencies (src/).

Index

Constants

This section is empty.

Variables

View Source
var Sources embed.FS

Sources holds src/*.js.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL