Skip to content

zenbase-ai/sharehtml

 
 

Repository files navigation

sharehtml

I've been using coding agents to write in markdown, make slides, and build interactive data analysis as static HTML files. Sending those files around still gets messy fast: you can't update them after sharing, and there's no way to get feedback inline. This is the reason I built sharehtml.

sharehtml screenshot

What is sharehtml?

Deploy a local document, get a link where others can view it and collaborate with comments, reactions, and live presence. Re-deploy to update the content at the same URL. Markdown and common code files are converted to styled HTML automatically.

  • CLI deployssharehtml deploy report.htmlhttps://sharehtml.yourteam.workers.dev/d/9brkzbe67ntm
  • Collaborative — comments, threaded replies, emoji reactions, text anchoring
  • Live presence — see who's viewing and their selections
  • Home page — your documents and recently viewed docs shared with you
  • Self-hosted — runs on your own Cloudflare account

Prerequisites

Team CLI Setup (Fork)

Use this flow when your team already has a deployed worker and you just need CLI access.

1) Install the CLI

bun install -g sharehtml

2) Configure your worker URL

sharehtml config set-url <worker-url>

3) Login

sharehtml login

4) Basic usage

sharehtml deploy my-report.html
sharehtml list
sharehtml open <id>
sharehtml delete <id>

Quick Start

git clone https://github.com/jonesphillip/sharehtml.git
cd sharehtml
pnpm install
npx wrangler login
pnpm run setup

The interactive setup script walks you through everything: deploying the worker, installing the CLI, and configuring authentication. Cloudflare Access is optional — the setup script asks if you want authentication. Without it, anyone with a link can view and comment.

To install the CLI directly:

# with Bun
bun install -g sharehtml

# or with npm (Bun still needs to be installed for the CLI runtime)
npm install -g sharehtml

If your team already has a sharehtml worker deployed, this is probably all you need — install the CLI, run sharehtml config set-url <worker-url>, then sharehtml login.

If you enable Cloudflare Access, you'll need a Cloudflare API token with these permissions:

  • Account > Access: Apps and Policies > Edit
  • Account > Access: Organization, Identity Providers, and Groups > Read

When it's done, try deploying one of the included examples:

sharehtml deploy example/coffee-report.html
# or try the markdown example:
sharehtml deploy example/sample.md
# or the interactive slideshow example:
sharehtml deploy example/nba-slideshow.html
# or deploy a code file:
sharehtml deploy apps/cli/src/index.ts

If a document with the same filename exists, the CLI will prompt to update it. Use -u to skip the prompt.

Manual deploy

If you've already run setup and just need to redeploy:

# Deploy the worker to Cloudflare
pnpm run deploy

# Build and link the CLI globally
cd apps/cli && pnpm build && bun link

Local development

pnpm dev

Starts the Vite dev server with Wrangler at http://localhost:5173. In dev mode, AUTH_MODE is "none" — no login required.

To use the CLI locally:

sharehtml config set-url http://localhost:5173
sharehtml deploy my-report.html

Architecture

CLI ──► Worker ──► R2 (HTML storage)
         │
Browser ◄┘──► Durable Objects
               ├── RegistryDO (users, documents, views)
               └── DocumentDO (per-doc comments, reactions, presence via WebSocket)
Component Purpose
Worker HTTP routing, auth, serves viewer shell and home page
RegistryDO Global Durable Object — users, document metadata, view history (SQLite)
DocumentDO Per-document Durable Object — comments, reactions, real-time presence over WebSocket
R2 Stores the actual HTML files
CLI Bun-based command-line tool for deploying and managing documents

CLI Command Reference (PRD)

Command Description
sharehtml deploy <file> Deploy an HTML, Markdown, or code file (creates or updates)
sharehtml list List your documents
sharehtml open <id> Open a document in the browser
sharehtml pull <id> Download a document locally
sharehtml delete <id> Delete a document
sharehtml share <document> Make a document shareable
sharehtml unshare <document> Make a document private
sharehtml login Log in through Cloudflare Access
sharehtml config set-url <worker-url> Set the sharehtml URL
sharehtml config show Show current configuration

Configuration

Worker auth configuration

Key Location Required Description
AUTH_MODE Worker secret (wrangler secret put) No "none" disables auth, "access" enables Cloudflare Access JWT verification. Defaults to no auth if unset.
ACCESS_AUD apps/worker/wrangler.jsonc (vars) When AUTH_MODE=access Cloudflare Access Application Audience tag (aud) from the Access application.
ACCESS_TEAM apps/worker/wrangler.jsonc (vars) When AUTH_MODE=access Cloudflare Access team name. For this deployment: zenbase.

Cloudflare Zero Trust Access application (dashboard)

  1. Open Cloudflare dashboard for account Synthesis and go to Zero Trust -> Access -> Applications.
  2. Create (or edit) the self-hosted application for the sharehtml worker URL (https://sharehtml.<your-subdomain>.workers.dev).
  3. Configure an allow policy using Emails ending in and set it to zenbase.ai.
  4. Save the application, then copy its Application Audience Tag (aud).
  5. Update apps/worker/wrangler.jsonc and replace REPLACE_WITH_ACCESS_APPLICATION_AUDIENCE_TAG in vars.ACCESS_AUD.
  6. Set auth mode to access:
npx wrangler secret put AUTH_MODE
# value: access

Project Structure

apps/
├── worker/
│   ├── src/
│   │   ├── index.ts                  # Hono app, routing
│   │   ├── routes/
│   │   │   ├── api.ts                # REST API (CRUD documents)
│   │   │   ├── viewer.ts             # Document viewer + WebSocket proxy
│   │   ├── durable-objects/
│   │   │   ├── registry.ts           # RegistryDO — users, docs, views
│   │   │   └── document.ts           # DocumentDO — comments, reactions, presence
│   │   ├── frontend/
│   │   │   ├── home.tsx              # Home page (document list)
│   │   │   ├── shell.tsx             # Document viewer shell
│   │   ├── client/
│   │   │   ├── shell-client.ts       # Viewer shell JS (presence, sidebar)
│   │   │   ├── collab-client.ts      # In-iframe collaboration (comments, reactions)
│   │   │   └── styles.css            # Shared styles
│   │   └── utils/
│   │       ├── auth.ts               # CF Access JWT verification
│   │       ├── registry.ts           # getRegistry() helper
│   │       ├── crypto.ts             # sha256 utility
│   │       ├── assets.ts             # Vite asset URL resolution
│   │       └── ids.ts                # nanoid generator
│   ├── scripts/
│   │   └── setup.ts                  # Interactive production setup script
│   └── wrangler.jsonc                # Cloudflare Workers config
├── cli/
│   └── src/
│       ├── index.ts                  # CLI entry point (commander)
│       ├── commands/                 # deploy, list, open, delete, config
│       ├── api/                      # HTTP client for worker API
│       └── config/                   # Local config store (~/.config/sharehtml)
└── packages/
    └── shared/                       # Shared types (messages, comments, reactions)

License

Apache-2.0

About

Deploy HTML, Markdown, and code files from the CLI. Get a shareable URL with live comments, reactions, and presence. Self-hosted on Cloudflare Workers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • TypeScript 80.4%
  • HTML 10.5%
  • CSS 9.1%