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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@stone-js/browser-adapter

v0.1.0

Published

Browser adapter for Stone.js. Enables SPA runtime support, unified event handling, and cookie management in the browser, part of the Continuum Architecture.

Readme

Stone.js - Browser Adapter

npm npm npm Maintenance Build Status Publish Package to npmjs Quality Gate Status Coverage Security Policy CodeQL Dependabot Status Conventional Commits

The Browser Adapter enables Stone.js to run directly in the browser, as a single-page or client-side rendered application, using the same universal interface and system design as backend deployments.


Introduction

In the Continuum Architecture, adapters are responsible for translating external context into internal system events. The browser adapter fulfills this role on the client-side by transforming browser-level navigation (like popstate or route events) into IncomingEvent objects that can be processed by your application.

This allows you to:

  • Run your full Stone.js system in the browser
  • Use the same handler and IncomingEvent logic as the backend
  • Handle routing, redirection, cookies, and more, entirely in the browser

This adapter is runtime-focused. It does not manage DOM events or UI logic, it is designed for SPA or SSR client runtime integration, not for UI frameworks.

Installation

npm install @stone-js/browser-adapter

This package is pure ESM. Make sure your project is ESM-compatible ("type": "module" in package.json) or configure your bundler accordingly.

Usage

You can activate the adapter either declaratively or imperatively.

Declarative API

import { Browser } from '@stone-js/browser-adapter'
import { StoneApp, IncomingEvent, IEventHandler } from '@stone-js/core'

@Browser()
@StoneApp()
export class Application implements IEventHandler<IncomingEvent> {
  handle(event: IncomingEvent): { message: string } {
    const name = event.get<string>('name', 'World')
    return { message: `Hello ${name}!` }
  }
}

Imperative API

import { defineStoneApp, IncomingEvent } from '@stone-js/core'
import { browserAdapterBlueprint } from '@stone-js/browser-adapter'

export const handler = (event: IncomingEvent) => {
  const name = event.get<string>('name', 'World')
  return { message: `Hello ${name}!` }
}

export const App = defineStoneApp(handler, {}, [browserAdapterBlueprint])

What It Enables

  • SPA Runtime Support Run your Stone.js app fully in the browser as an SPA. Routing and navigation are handled as synthetic events, passed into the system like any external request.

  • Route-First Event Handling Unlike backend adapters that respond to raw HTTP requests, the browser adapter listens to high-level route events (@stonejs/router.navigate, popstate, etc.) and converts them into IncomingEvent objects.

  • Unified Cookie API You can use the same cookie methods (getCookie(), setCookie(), etc.) on both client and server, without needing browser-specific abstractions.

Configuration Options

The browser adapter supports a single configuration option:

| Option | Type | Default | Description | | -------- | ---------- | ------------------------------------------ | ------------------------------------------------- | | events | string[] | ['popstate', '@stonejs/router.navigate'] | DOM or synthetic events to listen for as triggers |

Declarative Configuration

@Browser({ events: ['popstate'] })
export class App { /* ... */ }

Imperative Configuration

To configure adapter options imperatively, use the afterConfigure hook:

import { defineConfig, IBlueprint } from '@stone-js/core'
import { BROWSER_PLATFORM } from '@stone-js/browser-adapter'

export const AppConfig = defineConfig({
  afterConfigure(blueprint: IBlueprint) {
    if (blueprint.is('stone.adapter.platform', BROWSER_PLATFORM)) {
      blueprint.add('stone.adapter.events', ['popstate'])
    }
  }
})

Adapter selection happens at runtime. Always set configuration in afterConfigure() to ensure it's applied after the adapter has been resolved.

Summary

The @stone-js/browser-adapter enables Stone.js to operate in the browser with full support for routing, SPA-style execution, and context-aware event handling. It brings the same system architecture and behavior from your backend directly to the frontend, without code duplication or runtime hacks.

This adapter is a cornerstone for universal applications built with Stone.js.

API documentation

Contributing

We welcome contributions! See the Contributing Guide for details.