Guides
Host a website on Portaldot
Build a static site, store the output folder as a UnixFS directory, and serve it from the chain.
Deploy
Terminal (illustrative output)
npm run build # any static output: Vite, Astro, Next export, plain HTML
bun cli/potdrive.ts deploy ./dist
prepared 23 files · 412.6 KiB → 25 unique blocks
estimate 47.902 tPOT at most
stored ████████████████████ 25/25 blocks
site https://potdrive.anshverma.tech/ipfs/bafykbzace…/Or use Folder in the Drive. PotDrive builds a UnixFS directory: same input, same root CID, with shared files stored once. Redeploying an edited site only stores the blocks that changed.
How it is served
/ipfs/<root>redirects to/ipfs/<root>/so relative URLs resolve.- A directory with
index.htmlserves it. Without one, you get a directory listing. /ipfs/<root>/assets/app.jswalks the tree one verified block at a time, then serves the file with a type taken from its extension.- Files are immutable by CID, so responses carry
Cache-Control: immutable.
The sandbox
Stored HTML, SVG and JavaScript run under Content-Security-Policy: sandbox allow-scripts allow-forms allow-popups allow-modals allow-downloads, without allow-same-origin. The browser gives the page an opaque origin. It cannot read PotDrive's cookies, storage or wallet session, even though it is served from the same host.
Tips
- Use relative asset paths (
base: "./"in Vite) so the site works under/ipfs/<cid>/. - Hashed asset filenames dedupe well across deploys. Unchanged bundles keep their CIDs.
- Keep the total under 64 MiB in the Drive. The CLI has no fixed cap, but fees are per byte.