Single page applications: How they work and when to use one

A single page application (SPA) is a web app that loads a single web document and then updates its content with JavaScript, without loading new pages from the server. It suits interactive products used in long sessions, such as dashboards and editors. It needs extra work for search visibility and first-load speed.

What is a single page application?

A single page application (SPA) is a web app whose screens are drawn in the browser from JSON API data, so changing views triggers no full document load.

MDN defines an SPA as a web app implementation that loads only a single web document and then updates the body content of that document through JavaScript APIs such as Fetch. Some people call it a one page web app or a one page application; a one-page website, a single scrolling marketing page, is something else. A multi-page application, by contrast, asks the server for a new HTML document on every navigation.

Client-side rendering does the drawing: JavaScript receives data, builds the DOM, and updates the address bar through the History API. Three checks show whether a product is an SPA:

  • The URL changes while the tab does not reload, and scroll position, open panels and typed input survive the move.
  • After the first load, the browser's network panel shows fetch requests returning JSON, not HTML documents.
  • View source shows a near-empty body with a root element and script tags, unless the first view is server-rendered.

Web mail, online maps and project boards behave this way. Users stay in them for long sessions, and each action changes a small part of the screen.

Whether an SPA is the right call depends on who uses the product and how they find it. It fits tools people work in behind a login. An SPA is a weaker default for public pages that must rank in search, where crawlers and slow devices need HTML on the first response.

Our recommendation is a client-rendered SPA for logged-in workflows with heavy interaction, and server-rendered HTML for public pages that must be found, because each choice puts the rendering work where it costs least.

How does a single page application work?

A single page application works by loading one HTML document and its JavaScript once, then fetching data from a JSON API and redrawing the view in the browser on every later navigation. The sequence has five steps:

Pipeline diagram of a single page application's five ordered steps: first request for the app shell, bootstrap, data fetch from a JSON API, client-side route change, and state kept in browser memory.

  1. First request. The server returns the app shell: the minimal HTML, CSS and JavaScript that holds the persistent frame of the interface, such as the header, navigation and layout. A CDN can cache the shell and its hashed assets, so repeat visits skip most of the transfer.
  2. Bootstrap. The browser runs the JavaScript, which mounts the app and renders the shell with an empty content area.
  3. Data fetch. The app calls a JSON API, an endpoint that returns structured data as JSON and no markup. It renders the response into the content area.
  4. Route change. Client-side routing maps URL paths to views inside the browser. JavaScript intercepts a link click and uses the History API, the browser interface (pushState, replaceState, popstate) for changing the address bar and history entries without a document request. It then fetches the new view's data and swaps the content.
  5. State. Session data such as the auth token, cached responses and unsaved form input lives in browser memory. It survives route changes and is lost on a full reload unless the app writes it to storage.

After step 1, the server sees only API calls and no route changes, which is why server logs show no page views and analytics need explicit events. Every deep path, such as /orders/42, must also return the shell, or a browser refresh on that URL gets a 404.

For teams planning web application development around this model, the server's job reduces to serving static files and an API. When a framework renders the first view on the server, step 1 returns finished HTML and the app takes over from step 4.

Single page application vs multi-page application

Choose a single page application for interactive products used in long sessions behind a login, and a multi-page application for content that must be found through search. A multi-page application (MPA) is a web app where every navigation requests a new HTML document from the server.

That difference shows up in state. When cart contents live only in the page, pressing the back button in an MPA can drop them, so MPAs usually keep the cart in a server session or cookie. An SPA holds state in browser memory and has to manage it deliberately.

The two architectures compared on ten criteria:

Criterion Single page application Multi-page application
Navigation JavaScript swaps the view without a document reload Each link requests a new HTML document
First load Under client-side rendering, the shell and bundle load before content appears Server-rendered HTML can paint immediately
Later navigations Fetch JSON only, so cost depends on payload size Full document on every navigation
Core Web Vitals LCP on first load, INP across the whole session Each page measured as its own load
Search visibility Depends on crawler rendering, real links and per-view metadata Content is in the HTML response
State Held in browser memory, managed by the app Held on the server, reset on each page
Offline support Service worker can cache the shell and data Needs caching rules for each page
Analytics Route changes must be tracked as page views Page load records a view by default
Team split Front-end team owns the app, back-end team owns the API contract Back-end templates own pages, front-end adds behavior
Releases An open tab can run an old bundle against a newer API New version arrives on the next page load

The line between the two has blurred. Hybrid frameworks use server-side rendering for the first view and then behave like an SPA, so the table describes defaults per route, not whole products.

Benefits of single page applications

The benefits of a single page application show up in products where users stay for long sessions and every action needs an immediate response. Each benefit below names the condition where it pays off, because outside that condition it often does not.

  • Instant navigation between views. Client-side routing swaps content without a page reload, which pays off in tools such as a team chat client, where people switch channels and keep conversations going all day.
  • Preserved state. Drafts, filters, and scroll position stay in memory across views, which matters in editors, dashboards, and multi-step workflows where losing input costs the user real work.
  • Less data per interaction. After the first load, the browser requests only data from a JSON API, which pays off when views change often and the surrounding interface stays the same.
  • Independent front-end and back-end delivery. Teams that split web application development between front-end and back-end specialists can ship against the JSON API contract on separate schedules, and the same API can serve a mobile app.
  • Reusable interface components. A component framework such as React lets teams reuse the same components across views, which pays off in large products with a shared design system.

Public pages that depend on search traffic rarely meet these conditions, and there the costs outweigh these gains.

Drawbacks of single page applications

The main drawbacks of a single page application are delayed indexing, lost browser behavior on route changes, memory growth in long sessions, and old code running against newer APIs. Each follows from the app taking over work the browser does on a full page load, and each has an early signal you can monitor.

MDN's own list of trade-offs is close: SEO, more effort to maintain state, implementing navigation, and meaningful performance monitoring.

Hub and spoke diagram with a single page application at the center and four drawbacks around it: delayed indexing and soft 404s, lost focus and scroll, memory growth, and stale code against newer APIs.

Soft 404s and delayed indexing

JavaScript rendering for search crawlers is the step where a crawler runs a page's scripts to see content missing from the initial HTML. Google does this, but as a separate step with its own queue after crawling, so new pages can be indexed later than server-rendered ones.

The server also answers unknown URLs with the same shell and a success status, while the client draws a "not found" view. Crawlers read that as a soft 404, an error page that reports success, which Google's JavaScript SEO guidance tells you to avoid.

The early signal is Soft 404 entries in Search Console's page indexing report, plus public URLs whose raw HTML holds no content. The fix is a real 404 status from the server for unknown routes, and server rendering for public pages.

Lost focus and scroll position

A route change through the History API swaps the view without the reset a page load performs. Keyboard focus stays on a link that no longer exists, screen readers announce nothing, and the new view can open scrolled halfway down.

The early signal is a keyboard-only and screen reader walkthrough of any two routes. On each route change, move focus to the new view's heading, update the document title, and restore saved scroll position on back navigation.

Memory growth in long sessions

Event listeners, timers, subscriptions, and unbounded caches survive route changes unless the view releases them on unmount. Users in long sessions hit this first, and it shows up as sluggish interactions late in the day, which Core Web Vitals field data for INP can surface.

Take heap snapshots in DevTools before and after visiting the same routes repeatedly. If retained size climbs, the fix is cleanup on unmount, request cancellation with AbortController, and bounded caches.

Stale bundles against newer APIs

A tab left open for days keeps running the JavaScript it loaded, while the back end has since been deployed. The old client sends outdated payloads, and its lazy-loaded chunks can fail once old hashed files are removed.

The early signals are chunk-load errors and validation failures from old client versions right after a release. Keep API changes backward compatible for a fixed window, send the client version with each request, retain previous assets for a few days, and prompt a reload when versions mismatch.

Rendering options: Client-side, server-side, static and hybrid

A single page application does not need server rendering behind a login, but public pages that must be found through search usually do.

The four modes differ in where and when the HTML is produced, as web.dev's rendering overview describes. Client-side rendering builds the page in the browser: the server sends a near-empty document and JavaScript creates the DOM.

Server-side rendering builds the HTML on the server for each request. Static site generation builds it once at deploy time. Hydration attaches JavaScript to server-rendered HTML so the page becomes interactive.

Hybrid frameworks combine these modes. Next.js, a React framework that lets each route choose its own rendering mode, sends server-rendered HTML for the first view, hydrates it, and then hands navigation to client-side routing. After that first load the app behaves like any other SPA.

The decision rule is to choose per route, based on who needs the page and how often its data changes:

Route type Rendering Why Cost
Marketing pages, docs, blog Static generation HTML is ready before the request and can be served from a CDN Content is stale until the next build
Public pages with changing data (listings, profiles) Server-side rendering Crawlers and users get current content in the first response A server to run, and response time depends on data fetching
Dashboards, editors, settings behind login Client-side rendering Nothing needs indexing, and navigation after load is fast The first load waits for the JavaScript bundle

Hydration has a cost of its own. A server-rendered page can be visible before its scripts have run, so early clicks may get no response. The web.dev authors suggest server-side or static rendering over full rehydration where a page allows it.

This rule does not apply evenly to every team. If the whole product sits behind authentication, a pure client-rendered SPA is the cheaper build and needs no server rendering. If one public page is the only exception, pre-rendering that page may cost less than adopting a full hybrid framework.

SEO for single page applications

A single page application can rank, because Google renders JavaScript, but JavaScript rendering for search crawlers adds delay and failure points that server-sent HTML avoids. Google's JavaScript SEO basics describes crawling, rendering and indexing as separate steps.

Every SPA failure below comes from the gap between the first and the second. The four failure modes, with the early sign of each:

Failure mode What breaks Early sign
Render-queue delay Content exists only after JavaScript runs, so a page can wait in Google's render queue before its text is indexed New URLs show as discovered but not indexed; the raw HTML in URL Inspection is an empty shell
Unknown routes return success The server returns the same shell with a success status for every path, including pages that do not exist Search Console's page indexing report lists the URLs as Soft 404
Navigation without real links The router uses click handlers on buttons or divs, so crawlers find no URLs to follow A crawl of the site reaches only the home page
Shared metadata Title, description and canonical are set once in the shell and never updated A crawl export shows identical titles across different URLs

The fixes are mechanical. Client-side routing should use the History API to produce real paths, not fragment URLs. Google follows only <a> elements with an href attribute, so a link component should render one and let the router intercept the click.

For unknown routes, Google documents two options. Redirect with JavaScript to a URL for which the server returns a not-found status, or add a noindex robots meta tag with JavaScript.

Per-view metadata has to be written into the document on every route change, with a unique title, description and canonical for each URL. Keep noindex out of the initial HTML unless you mean it: Google's documentation says a page with noindex in the original response may skip rendering, so JavaScript cannot remove it later.

AI crawlers need separate verification. Google documents that it renders JavaScript, and its own guidance adds that not all bots can run JavaScript. Vercel's analysis of crawler traffic on its network found that none of the major AI crawlers it observed rendered JavaScript, including the crawlers of OpenAI and Anthropic. Content that exists only after client-side rendering may therefore not be read by them.

Server-side rendering for public routes removes the question, because the content is already in the first response for any crawler. Routes behind a login have no SEO exposure and can stay client-rendered.

Performance and Core Web Vitals in SPAs

In an SPA, LCP is decided on the first load and INP across the whole session, so the two metrics need different measurement. Core Web Vitals are Google's field-measured metrics for loading (LCP), responsiveness (INP) and layout stability (CLS), as web.dev's Core Web Vitals documentation defines them.

With client-side rendering, the app shell can paint almost immediately while the largest element still waits for the JavaScript bundle and an API response. A fast shell therefore says little about LCP. Audit the first load on a throttled mobile profile, and check what the LCP element is and when its data arrives.

Route changes after that first load are soft navigations. For years Core Web Vitals treated the whole visit as one page load, so a slow transition to a heavy screen never appeared in LCP.

web.dev's SPA guidance now says Chrome 151 introduced APIs that measure Core Web Vitals across SPA route transitions, and that the Chrome UX Report has started publishing experimental soft navigation metrics. Other browser engines do not support these APIs yet.

INP has always covered route changes, because it reflects interactions across the visit. Long sessions expose slow event handlers and expensive re-renders that a first-load audit misses. When INP is the problem, main-thread work during re-renders is the usual cause, and React performance optimization covers the fixes.

While the soft navigation metrics are experimental, add your own timing around route changes in real-user monitoring.

Two caveats apply. For an app used only behind a login, these metrics describe user experience and have no ranking effect. Low-traffic apps may also lack enough field data in the Chrome UX Report, which makes your own monitoring the only source.

Analytics in single page applications

Analytics in a single page application needs a page_view event on every route change, because client-side routing never triggers the document load that analytics tags normally count.

According to Google's enhanced measurement documentation, Google Analytics collects page_view each time the page loads or the active site changes the browser history state, so routers built on the History API are covered by default.

The catch is timing. A router often updates the URL before the new view sets its title, so the automatic event can carry the previous page's title. A router that calls replaceState for redirects or query parameters can also produce extra page views.

Give the event one owner. Either keep the automatic history-based collection and set the title before the route change, or turn it off and send page_view manually once the view has rendered, with the final path and title. Running both double-counts every navigation.

Security in single page applications

Security in a single page application depends on enforcing every permission on the JSON API, since anything client-side rendering ships to the browser can be inspected and changed by the user.

Hiding an admin route or a delete button improves usability and protects nothing. Anyone with a valid session can call the endpoint directly. Each endpoint should check the caller's identity, role, and ownership of the record on every request, whatever the interface shows.

Script injection is the main threat inside the browser. Sanitize or escape user-supplied content before it reaches the DOM, avoid APIs that insert raw HTML, and add a Content Security Policy that limits where scripts can load from. A successful XSS attack can read anything JavaScript can reach.

That affects token storage. Tokens kept in localStorage are readable by injected script, while a session cookie with the HttpOnly, Secure, and SameSite attributes is not. Cookie sessions need CSRF protection on state-changing requests, so choose based on which risk your team can cover.

Serve the app and the API over HTTPS only, so tokens and responses stay encrypted in transit.

Frameworks for building single page applications

A single page application is built in four steps: stand up the API, add client-side routing, choose a rendering mode per route, and deploy. A framework covers the routing and rendering steps, and React, Angular, Vue, Next.js and Nuxt are the main candidates.

  1. API. Build the JSON API first, in the back-end stack your team already runs. Node.js, Spring, .NET, Django and Rails all work, since the client only needs JSON over HTTP. Enforce permissions here.
  2. Routing. Use a router built on the History API, and render navigation as real <a href> links so crawlers and keyboard users get working URLs.
  3. Rendering. Decide per route: server-render public pages and client-render the screens behind login.
  4. Deploy. Client-rendered builds are static files for a CDN, with the host returning the app shell for unknown paths. Server-rendered routes need a Node runtime or edge functions.

React is a JavaScript library for building component-based interfaces, and Next.js adds routing and server rendering on top of it. Vue fills the same role with Nuxt, and Angular ships routing, forms and an HTTP client inside the framework itself.

Create React App is no longer a starting point. The React team deprecated it for new apps in February 2025 and recommends a framework. Existing apps can migrate to a framework or to a build tool such as Vite, Parcel or RSBuild.

When should you use a single page application?

Use a single page application for interactive products people work in during long sessions behind a login, and use server rendering or static site generation for content found through search.

The deciding factor is where the user starts. A visitor arriving from a search result needs a fast first view and a URL a crawler can read. A logged-in user needs the interface to keep its state across many actions.

The mapping by product type:

Product type Architecture Reason
Internal tools, admin dashboards, CRM SPA Long sessions, shared state across views, no search traffic to win
Browser-based editors and builders SPA Unsaved work on screen would be lost on a full page load
Messaging and real-time collaboration SPA Frequent partial updates over a persistent connection
SaaS with a public site and a logged-in app Hybrid Server-rendered or static public pages, SPA behind the login
E-commerce catalog, product and category pages Hybrid Server rendering for pages that rank, client-side routing for cart and checkout
Blogs, documentation, brochure and news sites Multi-page application or static site generation Content is read once and found through search, with little client state

Editors with drag and drop show the SPA case most clearly, because a reload discards the arrangement the user has built.

Connexio Talk, an outbound calling platform from US-based Connexio Labs, is a single page app of this kind. Netguru designed and implemented its Call Guide Builder and Question modules and refreshed the interface. The call guide editor works as an overlay on the text templates the client had used before, and users arrange a guide with HTML5 drag and drop.

The hybrid rows cover most new products. The framework renders the first view on the server, and hydration then turns the page into an SPA, so the choice is made route by route.

Skip the SPA when most visits are a single page view from a search result, or when your audience is on low-powered devices and slow networks. Skip it too when the team has no JavaScript experience to maintain client-side state. In those cases a multi-page application usually carries less build and monitoring effort.

Frequently asked questions

What is SSR vs SPA?

Server-side rendering (SSR) builds HTML on the server and suits public content, while a single page application (SPA) builds views in the browser and suits logged-in tools. Next.js renders the first view on the server, then the browser continues as an SPA. The choice is made route by route.

Is a single page application the same as a progressive web app?

No, a single page application describes how pages load, and a progressive web app adds installability and offline support through a manifest and service worker. An SPA can be a PWA, and so can a multi-page site.

Is React a single page application framework?

No, React is a library for component-based interfaces, and it produces a single page application only when the app renders in the browser with client-side routing. Next.js adds routing and server rendering, so a React app can also be server-rendered.

Can a single page application rank in Google?

Yes, when each view has its own URL, navigation uses real <a href> links, and the content renders without errors. Google renders JavaScript, but its documentation still calls server-side or pre-rendering a great idea for speed and for bots that cannot run JavaScript. Server-rendered HTML reaches more crawlers.

Are single page applications slower than multi-page sites?

Not by default: an SPA tends to load its first view more slowly and respond faster on later navigations, so session length decides. The browser must download and run JavaScript before rendering, which weighs on LCP, while route changes fetch only data. Code splitting and a server-rendered first view narrow the first-load gap.

Can you turn an existing multi-page site into a single page application?

Yes, usually in stages, provided the content can be served through an API or the existing templates can be wrapped in components. Start with logged-in screens that benefit from persistent state, and keep public, search-driven pages server-rendered. Rewriting content pages wholesale tends to cost search visibility without improving the product.

Choose the architecture route by route

A single page application fits the screens people work in for long sessions behind a login. Public pages that must be found through search need HTML in the first response, from server-side rendering or static generation. Most products need both, so decide per route and write the decision down before the first sprint.

If you are planning a new web product or a rebuild and want a second opinion on that split, tell us about the project and we will scope it with you.

We're Netguru

At Netguru we specialize in designing, building, shipping and scaling beautiful, usable products with blazing-fast efficiency.

Let's talk business