boba

package module
v0.6.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2026 License: MIT Imports: 1 Imported by: 0

README

boba - browser-oriented bubbletea adapter

Command Reference Latest Release GoDoc Code Of Conduct

boba is a Golang module that facilitates embedding BubbleTea Terminal User Interfaces (TUIs) into a Web Browser.

booba mascot

Installation

Go (server-side library and CLI tools):

go get github.com/btwiuse/boba

How and What?

The primary enabling technologies of this are:

Embedding a BubbleTea Application in a Web Browser

We can take entire BubbleTea applications and embed them into a Web Browser. The primary limitation is that all of its dependencies can also be compiled to WebAssembly.

Quickstart

The top-level boba.Run picks the right runtime for the build target, so a single main.go works for both the native terminal and the browser:

package main

import (
    "log"

    boba "github.com/btwiuse/boba"
)

func main() {
    if err := boba.Run(initialModel()); err != nil {
        log.Fatal(err)
    }
}

For easier porting from Bubble Tea — or when you need the program handle for Send, Quit, etc. — use boba.NewProgram:

func main() {
    bp := boba.NewProgram(initialModel())
    if _, err := bp.Run(); err != nil {
        log.Fatal(err)
    }
}

Build and run natively with go run ./cmd/myapp. Build for the browser with go run github.com/btwiuse/boba/cmd/boba-wasm-build -o web/app.wasm ./cmd/myapp/.

For finer control, the wasm subpackage exposes the browser bridge directly, and native code can construct a tea.Program the usual way.

Credits

Documentation

Overview

Package boba provides a platform-polymorphic entry point for running BubbleTea programs that target both native terminals and web browsers.

The same main.go works on both targets: when compiled for a native platform, Run runs the model with a standard tea.Program; when compiled with GOOS=js GOARCH=wasm, Run installs the JavaScript bridge that boba's web terminal uses.

package main

import (
    "log"

    boba "github.com/btwiuse/boba"
)

func main() {
    if err := boba.Run(initialModel()); err != nil {
        log.Fatal(err)
    }
}

For finer control — or to match the original Bubble Tea API during porting — use NewProgram:

bp := boba.NewProgram(initialModel())
if _, err := bp.Run(); err != nil {
    log.Fatal(err)
}

For more granular control, subpackages are available:

Index

Constants

This section is empty.

Variables

View Source
var NewProgram = tea.NewProgram

NewProgram creates a new BubbleTea program for the native terminal.

Functions

func Run

func Run(model tea.Model, opts ...tea.ProgramOption) error

Run executes the given BubbleTea model with the appropriate runtime for the build target.

Types

type Program

type Program interface {
	Kill()
	Printf(template string, args ...any)
	Println(args ...any)
	Quit()
	ReleaseTerminal() error
	RestoreTerminal() error
	Run() (tea.Model, error)
	Send(msg tea.Msg)
	Wait()
}

Program provides an abstraction over wasm.Program and tea.Program

Directories

Path Synopsis
cmd
boba-wasm-build command
boba-wasm-build compiles a Go package to WebAssembly, injecting js/wasm stubs into BubbleTea v2 and its dependencies at build time.
boba-wasm-build compiles a Go package to WebAssembly, injecting js/wasm stubs into BubbleTea v2 and its dependencies at build time.
Package wasm provides a bridge for running BubbleTea programs in the browser.
Package wasm provides a bridge for running BubbleTea programs in the browser.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL