Skip to main content

Hello World on WTTP

· One min read
DIP Team
Decentralized Internet Project

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-handler library
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.