How a page edits itself.
An nsite is web hosting on Nostr: whole HTML files, served to anyone who opens the address. That is all an nsite is. nsite-clay adds one thing: the page edits and updates itself, so the CMS sits inside the static HTML, not behind it.
You change the page. Click around and type, or open your browser's inspector and change the DOM there; the page does not care which. The new version is uploaded to your Blossom servers, and one replaceable event is republished that says which file / or /about-us now points to. Any nsite gateway renders it.
What Save does, exactly.
- Snapshot. The page clones its own DOM, cleans it up, and serialises the whole document. The toolbar and the debris browsers leave behind after editing commands never get saved.
- Blossom. Those bytes go to a Blossom server as one blob, addressed by its own sha256.
- Manifest. A replaceable NIP-5A event maps the path to that hash. Publishing it is the deploy.
Relays hold the manifest, Blossom servers hold the bytes, and the browser does the rest. Ownership is a keypair, so who may edit a page is not a row in somebody else's database.
The whole integration.
One attribute says who owns the file, one marks what people can type into, one script tag does the rest.
<!DOCTYPE html> <html lang="en" autosave nc:owner="npub1…"> <head><meta charset="utf-8"><title>Notes</title></head> <body> <h1 editable="single-line">My notes</h1> <div editable> <p>Type anything here.</p> </div> <script src="/nsite-clay.js"></script> </body> </html>
Save it, then open the file in a text editor: your words are in the HTML. The DOM is the database, so there is no other place for state to live.
Editing.
Mark a container editable and it becomes rich text for the owner and ordinary markup for everybody else.
Enter starts a new paragraph. Selecting text raises a floating toolbar whose first control is a block menu: Paragraph, Heading 1 to 3, Quote, Code block.
Keyboard shortcuts work as you would expect, and typing # , - or > at the start of a line does too.
What reaches the file is markup a person could have written by hand.
Gateways, and where your page is served.
A gateway resolves your manifest and serves the files. They all read the same events, so your site is not tied to any of them. If one is down, swap the hostname.
- nsite.lol, nosto.re and nwb.tf are public gateways.
- nsite.run, nsite.cloud and shakespeare.to are reference implementations. nsite.run also has the clearest explanation of what an nsite is.
- A CNAME from your own domain to your npub subdomain gets any of them to serve it, over plain HTTP. HTTPS needs a certificate for that name, which today means running your own gateway.
npm run devnetruns one on your laptop. - Assets are published at paths that carry their content hash, and each document watches its own manifest and reloads itself when a newer version appears. Nobody needs to know what a hard refresh is.