HOSTING
Static Hosting or a Server Runtime? Pick by Request
Use the work done on each web request to tell whether static hosting or an application runtime is the right fit for your site.
TL;DR: Static hosting is a fit when every public page can be built ahead of time or drawn in the browser. Add a runtime when the server must protect secret values, process writes or generate a different result for each request.
Introduction
The most useful static hosting decision is made one route at a time. A landing page, documentation article and customer invoice can live in the same product and have very different requirements. Ask what the server has to know and do when a visitor loads each one.
It is easy to read “static” as “unchanging.” Static sites can change often. It describes how a response is produced: uploaded files are already prepared by publication time, even when the browser later runs JavaScript and fetches live data.
What is static hosting?
Static hosting serves pre-existing files at web URLs without executing application code for each visitor request. A static generator can create one file per route from structured content. A JavaScript build can instead bundle code that renders in the browser after it loads. Both are valid if the remaining server work is handled somewhere appropriate.
A server runtime runs code in response to requests or background events. A common split is a static front end with a separately deployed API. You get a portable release for public files but still have a place for secure state and credentials.
Why choose by request?
- Public content that changes weekly can be rebuilt and published when someone edits it.
- A logged-in user's account data should be fetched through an authorized API; never include it in public output.
- A payment confirmation requires provider verification. A static success page is not evidence that the payment succeeded.
- Some services render pages uniquely for each visitor. If you need that at request time, check runtime support before choosing a host.
How to divide the workload
Start with routes that all visitors share
Product pages, documentation and public portfolios are often identical for everyone. Generate those pages ahead of time if useful metadata and readable content matter before JavaScript runs. A static site can implement navigation and progressive interaction without a persistent application process. If visitors only need to read a page, it is worth checking that it remains readable with JavaScript disabled.
Move private operations to an API
Receipts, subscriptions, private files and writes belong behind server authorization. Basing access on a browser-side variable or hiding a button is not a protection mechanism. Keep vendor credentials on the server. Use HTTPS and an explicit CORS policy for legitimate browser requests, while enforcing ownership and permissions independently.
Plan for slower or unavailable requests
An interactive static front end often calls APIs. Document an empty state for genuinely empty data, a loading state while data is incoming, and an error message for a request that fails. Keep the public pages useful even if the workspace API is briefly offline. If a build needs data, decide whether it uses a checked-in snapshot or needs to run in an environment that allows outbound network access.
| Route/action | Build-time/static approach | Runtime requirement |
|---|---|---|
| Product page | Generate HTML and shareable metadata | Usually none |
| Blog archive | Generate known public routes and refresh on publication | A runtime can add immediate editorial previews |
| Private dashboard | Serve the browser shell | Authenticate and authorize account API requests |
| Payment callback | Show a status page | Verify the provider event and update data |
Practical steps
- Draw a diagram with each page, its source data and when it needs to be fresh.
- Label any operation that needs credentials, private data or a write. Assign it to a backend service.
- Run the built front end without its development server. Check public pages, direct routes and the API's failure state.
- Document separate deployment and rollback steps for the front end and backend.
Common mistakes
- Selecting a host based on the name of a framework rather than its configured output mode.
- Shipping a client bundle with an administrative provider key.
- Expecting a static rollback to reverse a database or billing change.
Frequently asked questions
Do static sites allow JavaScript? Yes. The browser can run scripts delivered as static files.
Can a static site have sign-in? The interface can be static. Identity and protected data still require an identity provider and/or authorized backend.
Is a static site always faster? No. Bundles, images, API latency and page design still matter. Measure representative pages.
Can a CMS work with static hosting? Yes. The site can build from published CMS content and produce a fresh release when the content changes.
What if my framework generates server files too? Check for a documented static export mode, or run the dynamic parts with a compatible runtime.
Conclusion
Static hosting is a delivery model, so choose it for requests it can answer well. Compare the supported outputs in KairoBase with your route list, and use MDN's web application architecture material to identify server responsibilities.