SPA vs server-side rendering: which should you choose?

By

Updated

Tagged: Web Platform

Choose between a single-page app, server-rendered pages, and interactive islands by looking at navigation, shared state, loading, and maintenance.

Calling something a “single-page app” or a “server-rendered site” doesn’t tell you much anymore. A React app can send HTML straight from the server, an Astro page can hold a full interactive editor, and a regular multi-page site can animate smoothly between pages.

When I pick an architecture, I start with what people do on the page. Reading a blog post and editing a video ask very different things from the browser, and the real question is whether the interface needs to stay alive in memory while someone works.

Rendering and routing are separate decisions

It helps to split two things that often get lumped together: rendering and routing.

Rendering is how the UI gets built. With server rendering, the server sends HTML. With client rendering, JavaScript running in the browser builds and updates the page.

Routing is how URLs map to screens and what happens when someone clicks a link. The browser can ask the server for a fresh HTML document every time, or a client-side router can catch the click and swap the view in place.

You can mix and match these. A lot of apps server-render the first load, hydrate it in the browser, and then hand later link clicks off to a client router.

Fig 1 · 1/3Rendering, then routing
Server HTML

Because those hybrids are so common, check two things when you’re comparing setups. First, look at how much JavaScript the initial page still downloads and runs, because sending HTML from the server often ships the full client runtime right behind it. Second, click through to another route and see what happens: a fast first load can still turn into a sluggish second click if the next screen has to fetch both JavaScript and data before anything appears.

What hydration adds

Take a filterable table where the server sends the initial HTML. You see the rows right away, before any client code boots up.

If that page is built with React, hydration is the step that hooks your component logic up to the HTML already on screen. As React’s hydration documentation explains, the browser expects the first client render to match what the server sent.

Getting the HTML early helps, though the buttons and filters still won’t respond until the JavaScript finishes downloading and running. On a slower phone or laptop, that gap is easy to feel: the table looks ready to click, and nothing happens when you tap it. How noticeable that pause gets depends on your framework and how it handles interaction during startup.

That’s why server rendering can give you a quick first paint while still dumping too much JavaScript onto the browser. On the flip side, pure client rendering makes plenty of sense when there’s nothing meaningful to show until the person starts editing anyway. Look at both what arrives in the HTML and how much work the browser has to do before the controls respond.

If you want to dig deeper into how React handles this, read my server-side rendering guide.

A content page has a different starting point

Most of a blog post is text, links, and images. Browsers already handle all of that out of the box, along with opening links in new tabs, restoring history, selecting text, and submitting plain forms.

You might still want JavaScript for a search box or a course picker, and you can add those without wrapping the whole article inside a client-side app. That’s the main reason I like starting content sites with plain HTML and reaching for Astro, adding JavaScript only where a piece of the page needs it.

When your pages change much less often than people visit them, generating HTML at build time is hard to beat. The host hands back static files without spinning up app code on every request.

When a page depends on fresh data or who’s logged in, render it at request time instead. You don’t have to pick one mode for the whole site, either: serve your articles as static files, render the account page on demand, and set your caching and deployment rules to match each route.

Search engines need useful pages too

A public product catalog raises the stakes, because shoppers land straight on individual product URLs from search results instead of clicking in from the homepage.

Google does run JavaScript, though its JavaScript SEO documentation points out that crawling and rendering happen in two separate stages. If the first HTML response is just an empty app shell, Google has to execute your bundle before it can read the product details, and plenty of other bots won’t run JavaScript at all.

Send the core product content in the initial HTML, whether you build those pages ahead of time or render them per request. You can still power the image gallery with client-side code or let a client router handle follow-up clicks once the page is loaded.

Before you ship, test product URLs directly. Paste one into a fresh tab and hit reload to verify your host serves that route properly when the client router hasn’t booted yet.

Watch out for removed or missing products, too. A catch-all fallback that serves the same app shell with HTTP status 200 for every unknown URL leads to soft 404 issues. Whenever the server knows a product isn’t there, return a real 404 status (Google covers workarounds for client-rendered error pages in that same guide).

A quick way to sanity-check a storefront before generating thousands of URLs is to test two pages: one active product and one deleted product. Inspect the HTTP response for each, verify the page title, and click a category link to make sure moving to another product works cleanly.

With a private app, like the browser-based audio editor coming up next, search indexing barely factors in. Put that testing time into unsaved work and recovery instead, and keep the public marketing pages on their own rendering setup separate from the editor.

Islands give interactivity a boundary

An interactive island is a pocket of client-side JavaScript inside a page that is otherwise plain HTML. A calculator embedded in an article is the classic case: the calculator needs state and event handlers, while all the paragraphs around it stay static.

Astro’s islands documentation lays out how selective hydration works. You opt specific components into client JavaScript and decide when they load. Astro also has server islands for rendering dynamic chunks on the server independently, which is a separate feature from client hydration.

Client islands fit components with clear boundaries and self-contained inputs, like a pricing calculator, a filterable list, or a small product configurator.

They stop paying off once every island has to talk to every other island. If changing one filter needs to update a sidebar, an editor, a live preview, a toolbar, and a handful of dialogs, you’re really managing shared app state. You can wire up shared stores across islands, sure, but the moment you find yourself rebuilding a mini app framework to keep them in sync, you’re better off making that connected area a single client app.

Here’s how that calculator page looks when only the island loads client code:

An island inside an HTML pageAn article contains ordinary HTML alongside a calculator island. Only the calculator needs client state and event handlers.Article pageText, links, andimagesCalculator islandBrowser displaysHTMLJavaScript managesinputs and results

Livewire and HTMX keep rendering on the server

You don’t need a full reload every time a server-rendered page changes. Tools like HTMX and Laravel Livewire let the server swap out just the part of the page that updated.

Say you have an orders table with a status filter. Someone picks “Shipped”, the server queries the matching orders, and the browser replaces only the list while everything else stays put.

With HTMX, you put attributes directly on your HTML elements to say which endpoint to call and where to drop the result. Your server sends back an HTML snippet, and HTMX swaps it in. It works with whatever backend you already use to render HTML (my HTMX tutorial goes through how that feels in practice).

With Livewire, you write Laravel components in PHP and Blade. Clicking a button or submitting a form calls a method on your PHP component, Livewire re-renders it on the server, and its client script diffs the HTML and patches only what changed. That takes care of wiring component state to the browser without you writing custom fetch handlers.

Both are great options for an admin panel full of editable records, filters, and pagination. If you’re already in Laravel, Livewire plugs straight into the stack you know. If you want to stick to your own server routes and templates on any backend and sprinkle in partial updates, reach for HTMX.

Either way, you still have JavaScript running in the browser, and small local interactions shouldn’t go through the server at all. Opening a dropdown menu with Alpine.js is instant, whereas hitting the server just to toggle visibility adds needless lag.

The catch with server-driven updates is network latency. Anything that hits the server has to wait for a round trip. For a search box, wait until someone pauses typing before firing the request. For an audio editor’s playhead or a drawing canvas, frequent updates belong in the browser, and offline support needs its own client-side strategy.

Even here, routing stays independent from rendering. HTMX has hx-boost to intercept links, and Livewire gives you wire:navigate to fetch the next page in the background and swap it into the current document. The server still renders every bit of HTML, even when JavaScript handles the transition.

A single-page app earns its place through continuity

Now picture a browser-based audio editor. Someone has an unsaved project open, a clip selected, a playback position, and a panel layout on screen. Switching views has to keep that whole session alive, and plenty of interactions fire many times per second.

That’s where a persistent client-side app shines. Its router swaps the active view without tearing down the rest of the workspace around it.

Dashboards can fall on either side of this line, because “dashboard” covers a wide range of interfaces. A handful of reporting pages with date filters works fine with server rendering. A live trading terminal with streaming updates and linked panels needs that persistent client layer.

When you’re deciding whether a client app is worth the extra weight, ask three practical questions: how often do people switch views, what state needs to survive each switch, and how tightly are those screens tied together?

Notice that “does it have a login?” isn’t on that list. Server-rendered apps have handled authenticated pages for decades, so being behind a login doesn’t push you toward an SPA by itself. And a public app can still benefit from a client router if the work inside it depends on unbroken state. Look at how state behaves across screens instead of whether the URL is public or private.

Smooth navigation no longer proves you need a router

For years, that harsh white flash between page loads was reason enough for teams to reach for a client-side router.

Browsers handle that much better now. Chrome’s paint holding keeps the previous page visible briefly during qualifying navigations so you don’t get stuck staring at a blank frame while the next document renders.

On top of that, cross-document view transitions let supporting browsers animate directly between two separate HTML pages. You opt both documents in and stay within a few constraints, like same-origin navigation.

These browser features only handle visual polish: they still tear down JavaScript state on navigation, and a slow server response will still feel slow. What they give you is a way to make a multi-page site feel smooth without pulling in a client router just for page animations. Treat them as progressive enhancements, test them in the browsers your audience uses, and respect reduced-motion preferences so an effect that looks neat in a demo doesn’t get annoying on every click.

Sort out your rendering model and state needs first, and worry about navigation animations after that.

Count the requests the user waits for

People talk a lot about JavaScript bundle size when comparing rendering models, and bundle size does matter. The order of network requests matters just as much.

On a client-rendered route, the browser might download JavaScript, figure out which API request it needs, wait for the data, and only then render the page. When each step waits on the one before it, those round trips add up quickly.

A server-rendered route can fetch that data on the server before sending back HTML. You avoid the browser waterfall, though a slow upstream request will still hold up the response.

Here is one of those request sequences, where the arrows show dependencies rather than measured timings:

A client-rendered request waterfallIn this client-rendered example, the browser receives an HTML shell, loads JavaScript, discovers the API request, waits for data, and renders the content.Request pageReceive HTML shellLoad and runJavaScriptDiscover and fetchAPI dataRender usefulcontent

And here is the other sequence for comparison:

Fetching data before sending server-rendered HTMLIn this server-rendered example, the server fetches data and renders HTML before sending the content to the browser. A slow data request can still delay the response.Request pageServer fetches dataServer renders HTMLBrowser receives anddisplays content

Caching, parallel fetching, preloading, and moving non-essential work off the critical path can change how fast either setup feels.

Instead of guessing from architecture diagrams, test a real user journey on a throttled connection. Open a page directly, click to another route, hit the back button, and reload. Time two things: when useful content shows up on screen, and when the main action works.

Make sure you test with an empty cache too. A fast repeat visit on your laptop can easily hide a sluggish first load on someone else’s phone.

State has costs wherever you put it

If you keep a client app running across navigations, you have to plan for stale data. A user might leave a tab open while someone else edits the same record, and clicking around inside the app won’t trigger a fresh document load. You need clear rules for when to refetch data and how to show conflicts when edits collide.

Server-rendered pages have their own state headaches. Unsaved form input can disappear when a user navigates away, and a late server response can land after they have moved on. Caching adds another trap: if your cache rules ignore authentication, you can end up serving stale or wrong content.

When a page mostly has a few forms, server rendering with small interactive pieces keeps those edge cases easy to follow. Once you’re building a dense workspace with lots of moving parts, pulling state into a central client store can be much easier to manage. Go with whichever setup leaves you with fewer hidden rules to track for that screen.

One habit pays off no matter how you route pages: put shareable state in the URL. If you pick a date range on a report, you should be able to copy the link and share it. Temporary UI state like a drag position doesn’t belong in the address bar.

Failure behavior deserves a trial

Before you commit to an approach, break the network on purpose and see how the interface holds up.

Watch what happens when a navigation fails. Does the previous screen stay usable, can the user retry, and does the URL still match what’s on screen? Also test what happens if a JavaScript chunk fails to load right after a deploy, and make sure the user can recover without losing their work.

Each rendering model has its own failure paths to check. On a server-rendered form, verify that an error doesn’t wipe out the values the user just submitted. If you’re using an interactive island, try interacting with it before its JavaScript loads. For a client-rendered app, test both a failed initial startup and API errors that happen later.

Check accessibility in the same pass. When you handle navigation in JavaScript, you have to manage focus yourself and make sure assistive technology can follow meaningful page changes. Regular browser navigation takes care of part of that automatically, so custom interfaces need deliberate work to keep it intact.

If you want a refresher on what the browser already gives you out of the box, take a look at the free HTML course. Once you know what plain links and forms do on their own, it’s much easier to judge which enhancements you need.

A product can use several approaches

You don’t have to pick one rendering model for your entire product. If you’re building a marketing site alongside a complex editor, give each part the default that fits it.

Start the marketing pages as HTML and add small interactive components only where they help. Build the editor as a client-side app if its state and workflow justify it, and leave account settings as ordinary server-rendered forms. Here’s how that split can look across one product:

Different rendering choices within one productA product can use HTML with islands for marketing, server-rendered forms for account settings, and a persistent client application for its editor.One productMarketing: HTML +islandsSettings:server-renderedformsEditor: persistentclient app

Mixing approaches like this does create boundaries. You have to keep authentication and navigation consistent across sections, and decide cleanly how the editor loads and saves data. Still, those boundaries match real parts of the product, which is often easier to maintain than forcing every marketing page and settings form into the editor’s architecture.

If you’re working on a smaller app, start with server-rendered pages and add interactivity only when you run into a concrete need. You can always move a section to a client app later if it grows into a workspace with deeply shared client state.

When you’re ready to decide, build the screen with the hardest interaction first. Use it on a slow connection, navigate away, and come back to see what state you need to preserve and how much work it takes to keep in sync.

Want me to talk about your product? You can sponsor this site.

Related posts about platform: