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

@lokal-server/ts-sdk

v0.1.1

Published

TypeScript SDK for Lokal external apps.

Readme

@lokal-server/ts-sdk

TypeScript SDK for Lokal external apps. Lokal is a self-hosted file/data hub; this SDK helps apps define a manifest, authenticate a Lokal user, register the manifest, and read/write app-private JSON data.

Install

npm install @lokal-server/ts-sdk

Define an app

import { createLokalClient, defineLokalApp } from '@lokal-server/ts-sdk';

const recipeSchema = { type: 'object' };
const settingsSchema = { type: 'object' };

const manifest = defineLokalApp({
  name: 'Recipe Box',
  slug: 'recipe-box',
  collections: {
    recipes: recipeSchema,
    settings: settingsSchema,
  },
});

const lokal = createLokalClient({
  instanceUrl: 'https://files.example.com',
  manifest,
});

defineLokalApp() preserves collection names as literal TypeScript keys, so lokal.collection('recipes') is accepted and unknown collection names are rejected by TypeScript.

Sign in

await lokal.auth.signIn({
  email: '[email protected]',
  password: 'password',
  tokenName: 'Recipe Box',
});

Sign-in posts the manifest to /api/platform/auth and stores the returned app token in memory. You can also manage the token yourself:

lokal.setToken(savedToken);
const token = lokal.getToken();
lokal.clearToken();

The SDK does not persist tokens to localStorage or sessionStorage; consuming apps should choose their own persistence strategy.

Collection records

const recipes = lokal.collection('recipes');

const created = await recipes.create({ title: 'Pancakes' }, { key: 'pancakes' });
const all = await recipes.list({ limit: 20 });
const one = await recipes.get(created.id);
const updated = await recipes.update(created.id, { title: 'Blueberry Pancakes' });
await recipes.delete(updated.id);

Singleton values

Use singleton values for one JSON document per collection, such as settings.

await lokal.collection('settings').setValue({ theme: 'dark' });
const settings = await lokal.collection('settings').getValue();

Custom fetch

By default the SDK uses global fetch. Pass a custom implementation for tests or non-standard runtimes:

const lokal = createLokalClient({
  instanceUrl: 'https://files.example.com',
  manifest,
  fetch: customFetch,
});

Errors

Missing tokens throw a clear Error. Non-2xx API responses throw LokalApiError with status, message, and parsed body when available.

import { LokalApiError } from 'lokal-ts-sdk';

try {
  await lokal.collection('recipes').list();
} catch (error) {
  if (error instanceof LokalApiError) {
    console.error(error.status, error.body);
  }
}

Contracts

The main Lokal repo owns the API contracts. Copies are kept in contracts/:

  • contracts/openapi.json
  • contracts/lokal-manifest.schema.json

Update them with:

npm run contracts:update

If the OpenAPI contract changes, update SDK types, wrappers, and tests in the same change.

Publishing

The package is configured for public npm publishing with private: false, files: ["dist", "contracts", "README.md"], and publishConfig.access: "public".

Do not publish automatically. When ready, run checks and publish explicitly:

npm run check
npm publish