Skip to content
nirvanacpPublic

About

Make your browser an app store.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Let

@nirvanacp/let on npm @nirvanacp/sdk on npm @nirvanacp/applet-tools on npm @nirvanacp/servelet-tools on npm Go reference
Publish Latest release Genesis 0.3.0 Node 24.15.0 or later Go 1.24 or later MIT licence

Let is a framework for building phone apps on top of websites you already use. Your app draws its own screens, while the real website runs underneath in the same session, signed in as you. Your code reads the website's pages into records and acts on them with taps and form fills. Any page your app doesn't customize shows as the website itself.

You don't need access to the website's code or API. A Let app works with the pages the website already serves.

Let apps run in Genesis, an Android app. Let gives you everything else: the SDK, the build tools, a Go library for backends, and instructions a coding agent can follow to build an app from a plain description.

How an app is made

An app has one or two parts:

  • An applet is the app's screens and its page logic. It is a web app in any framework, plus an optional page module that runs inside the website's pages and turns them into records.
  • A servelet is the app's own backend, when it needs one: a small Go service with a SQLite database. Genesis runs it on the phone as WebAssembly, so there is no server to host.

Where the data lives decides which parts you need:

Data Where it goes
What the website already keeps: posts, votes, its own bookmarks Stays on the website. The applet reads it from the page
A few small things your app owns: preferences, read state, a short list of tags The applet's document storage. No servelet needed
App data that needs queries, search, sorting, validation or computed results A servelet

Quick start

You need:

  • Node 24.15.0 or later
  • adb from the Android SDK platform tools
  • An Android 8.0 (API 26) or later emulator, or a phone with USB debugging
  • Go 1.24 or later, only if your app has a servelet

The tools are tested on macOS. Linux is expected to work. Windows is untested.

  1. Install Genesis Dev. Download genesis-0.3.0-developer.apk from the Genesis releases and run adb -s <serial> install genesis-0.3.0-developer.apk (adb devices lists the serials). Genesis Dev installs beside the regular Genesis app and accepts development installs; the regular app refuses them.

  2. Create an applet, build it and put it on the device:

    npx @nirvanacp/applet-tools@0.3.0 create my-applet --origin https://news.ycombinator.com
    cd my-applet
    npm install
    npx let-applet check .
    npx let-applet build .
    npx let-applet dev install . --device <serial> --application app.nirvana.genesis.dev

    Add --ci to create if you publish on GitHub: it also writes workflows that check and release the applet.

  3. Open Genesis Dev on the device. Your applet is in its list. npx let-applet dev status --device <serial> --application app.nirvana.genesis.dev shows what is installed.

  4. Need a backend? Start a servelet next to the applet with npx @nirvanacp/servelet-tools create servelets/notes, then follow the servelet guide.

The getting started guide walks through the same steps in more detail.

Build with a coding agent

Let is written so a coding agent can build the app for you. Each new applet has the instructions at my-applet/let/AGENTS.md. Point your agent at that file and describe what you want:

Read let/AGENTS.md. Build an app for https://example.com that keeps my reading list with tags, sorted by date added, and lets me search it.

The agent decides whether the app needs a servelet, looks at the website, writes the page module, the screens and the backend, then installs the app and checks that it works. It asks only about choices that change what you get.

Run npx let-applet kit export --out <directory> to copy the same instructions anywhere else.

What the code looks like

A page module runs inside the website's page. Its readers turn the page into keyed records:

// src/page.ts
import { definePageModule, list } from "@nirvanacp/sdk/page";

export default definePageModule({
  readers: {
    stories: list<{ title: string; url: string }>({
      root: "body",
      items: "tr.athing",
      key: row => row.id,
      read: row => {
        const link = row.querySelector<HTMLAnchorElement>(".titleline > a")!;
        return { title: link.textContent ?? "", url: link.href };
      },
    }),
  },
});

Your screens watch a reader. A watch reads the page once and then sends only the records that change. Actions like click act on the real page:

// src/main.tsx
import { record } from "@nirvanacp/sdk";
import { useGenesis, useWatch } from "@nirvanacp/sdk/react";

function Stories() {
  const genesis = useGenesis();
  const stories = useWatch<never, { title: string; url: string }>(
    "home:stories", { reader: "stories" }, { context: "primary", when: [{ pattern: "/" }] },
  );
  if (stories.status === "error") return <p role="alert">This page couldn't be read.</p>;
  if (stories.status === "loading") return <p role="status">Loading…</p>;
  return (
    <ul>
      {stories.order.map(key => (
        <li key={key}>
          <button onClick={() => genesis.context("primary").click(record("home:stories", key), { navigates: true })}>
            {stories.records[key].title}
          </button>
        </li>
      ))}
    </ul>
  );
}

A servelet is an ordinary Go http.Handler:

package main

import (
	"net/http"

	"github.com/nirvanacp/let/go/servelet"
)

func init() {
	if err := servelet.Migrate(`CREATE TABLE notes (id INTEGER PRIMARY KEY, text TEXT NOT NULL)`); err != nil {
		panic(err)
	}
	mux := http.NewServeMux()
	mux.HandleFunc("GET /health", func(w http.ResponseWriter, r *http.Request) {
		servelet.JSON(w, http.StatusOK, map[string]bool{"ready": true})
	})
	servelet.Serve(mux)
}

func main() {}

The applet declares the servelet as a service and calls it like any HTTP backend. let-applet build compiles the servelet into the applet's bundle.

Packages

Package Version What it is
@nirvanacp/sdk 0.3.0 What your applet imports: the client, page modules (/page), the router (/router) and React bindings (/react)
@nirvanacp/applet-tools 0.3.0 The let-applet command
@nirvanacp/servelet-tools 0.3.0 The let-servelet command, with the Go library
@nirvanacp/let 0.0.2 The shared rules underneath: manifest validation, route matching, protocol types, error codes and the compatibility table
github.com/nirvanacp/let/go/servelet The Go library every servelet imports

create adds the SDK and the tools to your applet for you. The other packages install @nirvanacp/let themselves. Install it directly only to use its rules in your own code:

npm install @nirvanacp/let@0.0.2 --save-exact
import { FRAMEWORK_VERSION, COMPAT } from "@nirvanacp/let";

Tools

let-applet (also installed as genesis-applet) works with applets:

Command What it does
create <dir> --origin <https://host> Starts an applet from the react (default) or vanilla template
check <dir> Checks compatibility and the manifest, type-checks, and loads the page module
build <dir> Bundles the screens, the page module and any servelets into dist/
dev install <dir> --device <serial> Installs the last build on a device. Add --application app.nirvana.genesis.dev for Genesis Dev
dev status, dev cookies Lists installed applets; copies a desktop Chrome sign-in to Genesis Dev
publish <dir>, release <dir> Writes the published build and tags the version for a GitHub release
kit export --out <dir> Copies the agent instructions and guides

let-servelet works with servelets:

Command What it does
create <dir> Starts a servelet, optionally with --framework chi|gin|echo
build <dir> Compiles it to dist/servelet.wasm
check <dir> Builds it and runs its checks.json against a throwaway database
run <dir> --port 8790 Serves it on 127.0.0.2 so you can try it from your computer

Every command accepts --json. check and build run your project's code, so run them only on code you trust.

What you can build today

Part Available Not available yet
Applet Web UI in TypeScript (default) or JavaScript, any web framework React Native, native Java or Kotlin
Servelet Go with the standard library router (default), chi, gin or echo JavaScript on Node.js
Runtime On the phone, as WebAssembly On the phone as a native process, in the cloud

The tools refuse a choice that isn't available and tell you which ones are.

Guides

Guide What it covers
Getting started From an empty folder to an applet on a phone
Page modules Readers and commands that run in the website's page
Navigation Routes, contexts, Back and the router
Services and data Document storage, services and servelets
SDK reference Every SDK call
Verification Checking an applet on a device
Publishing Publishing and releasing an applet
Servelets Routes and errors, tables and migrations, the Go library

Versions and compatibility

The SDK and the tools share a version line with Genesis: SDK and tools 0.3.0 build applets for Genesis 0.3.0. Pin them exactly in your applet; create does this for you. @nirvanacp/let has its own version, 0.0.2, and the SDK and tools depend on the exact version they need.

If your applet and Genesis don't match, you find out early:

  • let-applet check and build stop with APPLET_INCOMPATIBLE before building anything.
  • Genesis lists the applet as needing an update, or a newer Genesis, and doesn't open it. dev install and dev status show what differs.

Your applet's own version, in its package.json, is yours to choose.

Let is in early development. Expect breaking changes until the first stable release.

Contributing

Pull requests go to develop. Changes to the packages, the tools, the Go library and the guides follow AGENTS.md in the Genesis repository. When a change affects what applet or servelet authors can do, update the matching guide in factory/ in the same pull request. A merge to main publishes to npm the packages whose version isn't there yet, and tags the release.

Licence

MIT, see LICENSE.

About

Make your browser an app store.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages