npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

swiftbase-sdk

v1.0.2

Published

TypeScript SDK for integrating customer apps with Swiftbase

Downloads

219

Readme

Swiftbase TypeScript SDK

TypeScript SDK for integrating customer applications with the Swiftbase platform. Supports SDK initialization, authentication, user profiles, identity management, database queries (with real-time WebSocket subscriptions), and S3-compatible cloud storage.

Installation

Install the package via npm:

npm install swiftbase-sdk

Getting Started

Initialize the SDK

Initialize the SDK at the entry point of your application:

import { initializeSdk } from "swiftbase-sdk";

initializeSdk("your-project-id");

Authentication

The SDK provides several authentication mechanisms, including credentials, redirect-based OAuth2/OIDC, and service logins.

User Login (Email / Password)

import { loginWithPassword } from "swiftbase-sdk";

const userProfile = await loginWithPassword({
  projectId: "your-project-id",
  email: "[email protected]",
  password: "password123",
});
console.log(`Welcome back, ${userProfile.firstName}!`);

Password-less / Redirect OIDC Login (Browser Environment)

import { loginWithRedirect, handleRedirectCallback } from "swiftbase-sdk";

// Trigger OIDC redirect flow
await loginWithRedirect({
  redirectUri: window.location.origin + "/callback",
  state: "secure-random-state",
});

// On the callback route:
const profile = await handleRedirectCallback();

Service Login (Client Credentials)

import { loginService } from "swiftbase-sdk";

const tokenResponse = await loginService(
  "your-project-id",
  "your-service-id",
  "your-service-secret",
);

Manage Session

import { isLoggedIn, logout, getAccessToken } from "swiftbase-sdk";

if (isLoggedIn()) {
  const token = await getAccessToken();
  console.log("Logged in token:", token);
}

await logout();

User Profiles

Retrieve and manage user profile details:

import { getProfile, updateProfile, changePassword } from "swiftbase-sdk";

// Get current profile
const profile = await getProfile();

// Update profile details
const updatedProfile = await updateProfile({
  firstName: "Jane",
  lastName: "Doe",
});

// Change Password
await changePassword({
  currentPassword: "old-password",
  newPassword: "new-password",
});

Database (Real-time & REST Queries)

Query your Swiftbase databases using a fluent, type-safe builder. Query execution automatically utilizes WebSockets if available, otherwise it transparently falls back to REST.

import { db } from "swiftbase-sdk";

// Initialize builder
const usersDb = db("my_database")("users");

// Fetch multiple rows
const results = await usersDb
  .select("id", "email", "firstName")
  .where("roles", "admin")
  .limit(10)
  .offset(0);

// Insert a row
await db("my_database")("users")
  .insert({ firstName: "Alice", email: "[email protected]" })
  .execute();

// Update rows
await db("my_database")("users").where("id", "user-id").update({ firstName: "Bob" }).execute();

// Delete rows
await db("my_database")("users").where("id", "user-id").delete().execute();

Real-time Subscriptions

Subscribe to database changes using WebSockets:

const unsubscribe = db("my_database")("posts")
  .where("status", "published")
  .listen((change) => {
    console.log("Database event:", change.event); // 'insert' | 'update' | 'delete'
    console.log("Record data:", change.data);
  });

// To stop listening later:
unsubscribe();

Object Storage (S3-Compatible)

Interface with your storage buckets using the S3-compatible Storage module.

import { Storage } from "swiftbase-sdk";

const storage = new Storage({
  bucket: "my-bucket",
  // region: "us-east-1", (Optional, default is us-east-1)
  // accessKeyId: "key", (Optional: signs requests with SigV4; defaults to bearer token auth)
  // secretAccessKey: "secret"
});

// List files
const { contents } = await storage.listObjects({ prefix: "uploads/" });

// Upload a file
await storage.putObject("uploads/hello.txt", "Hello World!", {
  contentType: "text/plain",
});

// Get a file
const text = await storage.getObjectAsText("uploads/hello.txt");
const json = await storage.getObjectAsJson("uploads/data.json");

// Delete a file
await storage.deleteObject("uploads/hello.txt");

Identity & Role Management (Admin only)

import { getUsers, assignRole, unassignRole } from "swiftbase-sdk";

// List all users in a project
const allUsers = await getUsers("your-project-id");

// Assign a role
await assignRole("user-id", "admin");

// Revoke a role
await unassignRole("user-id", "admin");

Running Tests

Run the test suite using Vitest:

npm run test