Hello World on WTTP
· One min read
Every new technology needs a “Hello World” moment.
Here’s how to publish your first WTTP resource in under 10 lines of code.
🛠 Prerequisites
- Node.js installed
- A funded wallet (on testnet is fine)
- The
wttp-handlerlibrary
npm install wttp-handler
🖊 Write Your First Resource
import { WTTPHandler } from 'wttp-handler';
const handler = new WTTPHandler();
await handler.fetch('wttp://my-first-site/index.html', {
method: 'PUT',
headers: {
'Content-Type': 'text/html',
'Content-Location': '/index.html'
},
body: '<h1>Hello WTTP!</h1>'
});
That’s it. You’ve just published a permanent, onchain webpage.
🌍 Viewing Your Site
Share your link in the format:
wttp://[site-address]/index.html
Anyone with the WTTP client can now access your page.
Congratulations — you’ve taken your first step into the decentralized web.
From here, the possibilities are endless.
