Static File Serving
Smallweb can serve static files without any configuration. Just drop your files into a directory and they're live.
Basic Static Site
Create a directory with your static files:
mysite/
├── index.html
├── style.css
├── script.js
└── images/
└── logo.png
That's it! Your site is now available at https://mysite.yourdomain.com.
Static Files with Dynamic Routes
You can combine static files with a main.ts for hybrid apps:
export default {
fetch: async (request: Request) => {
const url = new URL(request.url);
// Handle API routes
if (url.pathname.startsWith("/api/")) {
return new Response(JSON.stringify({ hello: "world" }), {
headers: { "content-type": "application/json" }
});
}
// Fall through to static file serving
return new Response(null, { status: 404 });
}
}
MIME Types
Smallweb automatically detects and sets appropriate MIME types based on file extensions.