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

@bablic-io/sdk-core

v1.2.0

Published

Engine behind Bablic server-side rendering: translates pages on the server with your Bablic project.

Readme

@bablic-io/sdk-core

The engine behind server-side rendering for Bablic. It translates a page on the server with your Bablic project's translations and returns finished HTML in the visitor's language.

You need a Bablic account and project. New to Bablic? Sign up.

Most sites want an adapter instead:

Use this package directly to support another host. Requires Node.js 22.

Install

npm install @bablic-io/sdk-core

Translate one page

import { MemoryCache, translateDocument } from '@bablic-io/sdk-core';

const cache = new MemoryCache();

const result = await translateDocument({
  html, // original-language HTML, including the Bablic script tag
  url: 'https://example.com/fr-fr/pricing', // the translated URL being served (example)
  cache,
});

if (result.status === 'complete') {
  // result.html: translated page
  // result.textMap: original → translated strings, for framework data
  // result.links: your project's link rules and the links that changed
} else {
  // 'skipped': not translated on the server (plan without server-side rendering, or the
  // project doesn't translate this page); serve the original.
  // 'failed': never serve or cache the result; see result.reason.
}

translateDocument reads your project from the page's Bablic script tag, translates the page on the server, and waits until translation is complete.

Serve a host: createPageHandler

The request flow the adapters share: routing, fetching the original page from the same site, translating, caching, the editor bypass and the failure rule.

import { createPageHandler, MemoryCache } from '@bablic-io/sdk-core';

const pages = createPageHandler({ project: 'P0000', cache: new MemoryCache() });

// In your request handler:
const response = await pages.handle(request); // undefined: not a translated URL

For a URL that isn't translated, await pages.explain(request) says why (for example, which language folders the project has), for an x-moxie-reason header or a log line.

project is your Bablic project key. Translated URLs come from your Bablic dashboard settings (language folders or subdomains); projectResolver and routeFromConfig expose that routing on its own.

Options match the adapters (project, resolve, pageTtl, timeoutMs, cache, moxie, editorCookie, onResult, onUnsupported, host, fetch), plus host hooks: buildId, sourceHeaders, ignoreParams, dropRequestHeaders, transformHtml and absoluteRedirects. See the @bablic-io/sdk-vercel README for behavior, response headers and hosting rules.

Other exports

  • CacheStore: the cache interface (get, set with ttl and tags, expireTag). MemoryCache implements it.
  • createRevalidateHandler({ secret, cache }): signed purge endpoint that clears cached pages, or the cached project config with {"config": true}.
  • rewriteHref(href, rules), localizeHref(href, links): apply your project's link rules to a URL, as Bablic does in the page.
  • projectResolver({ project, cache }), routeFromConfig(config, url): your project's translated URLs.
  • isCrawler(userAgent), isStagingUrl(url).

Links

License

MIT