Building a single page application: what it takes, and when it is worth it.
The five parts every SPA needs, the order we build them in, the tooling that holds up in 2026, and the jobs where a single page app is the wrong tool.
To build a single page application you need five things working together: an HTML shell, a router that maps real URLs to views, components that draw each view, a way to fetch and save data through an API, and hosting that sends every route to the same entry file. A modern tool like Vite, or a framework like Next.js or React Router, sets most of that up in minutes. Getting a demo running is the easy part. The hard part is the decisions around it: which pages search engines must be able to read, how logins and data are protected, and whether the project should be a single page app at all.
That is the short version. Below is how the pieces fit, the order we build them in, and the parts most tutorials leave out. If search visibility is your main worry, our guide to SEO for single page apps covers that side in depth.
What a single page application actually is
A traditional website asks the server for a new HTML document on every click. A single page application (SPA) loads one document once, then uses JavaScript to swap what is on screen, change the address in the browser bar, and fetch only the data it needs. The page never fully reloads, which is why a well-built SPA feels quick once it is open.
The Next.js team defines a "strict SPA" in its single page application guide as an app served from one HTML file, where every route, page transition and data fetch is handled by JavaScript in the browser. That definition shows the tradeoff plainly: everything depends on JavaScript arriving and running before anyone sees anything useful.
Web email clients, online maps and project boards are the familiar examples. So are many of the client portals, booking tools and internal dashboards that Ontario businesses now ask us about.
How a single page application works, in five parts
| Part | What it does | What goes wrong when it is skipped |
|---|---|---|
| The shell | The one HTML file the server sends: a title, a root element and the script tags | Every page shares one title and description, and crawlers and link previews see an empty page |
| The router | Maps each URL to a view and updates the address bar without a reload | Views share one URL or hide behind #/ fragments, so nothing can be bookmarked, shared or indexed |
| Views and components | Draw each screen from reusable pieces | Duplicated code that drifts, where one fix needs five edits |
| Data and state | Fetch from and save to an API, and keep the screen in step with what is stored | Stale screens, double submissions and lost form input |
| Build and hosting | Bundle and split the code, and serve every route from the entry file | Large downloads on phones, and 404 errors when someone refreshes a deep link |
The router deserves a closer look, because it is the part that makes an SPA behave like a website. When someone clicks a link inside the app, the router stops the browser's normal page load, calls history.pushState() to put the new path in the address bar, and draws the matching view. When they press Back, the browser fires a popstate event and the router draws the previous view. MDN's History API reference covers the details. Every framework router is a more careful version of that loop, with nested layouts, loading states and code splitting added on top.
How to build one: the order we work in
Tutorials start with code. On a client project the code comes surprisingly late, because the expensive mistakes are made before anyone opens an editor.
- List the screens and who sees them. Mark each one public or behind a login. This one list decides the rendering approach, the permissions model and most of the cost.
- Give every screen a real URL.
/jobs/,/jobs/1042/,/settings/team/. If a person might bookmark it, send it to a colleague or come back to it from an email, it needs its own path. - Design the data before the screens. What is stored, who can change it, and what reports the business will want in a year. Screens are easy to redraw. A data model is not.
- Choose the rendering per route. Public pages get finished HTML from static or server rendering. Logged-in screens can render in the browser.
- Scaffold with a maintained tool, not a hand-rolled bundler setup. The comparison below covers the usual options.
- Build the API and authentication, with permissions checked on the server for every request, not only hidden in the interface.
- Build the views in the order people click through them, so the client can use real flows early and react to them.
- Configure hosting and the fallback route, then test a hard refresh on a deep link, a missing page and a slow phone connection.
- Add the launch checks: page views on route changes, error logging, backups and a real 404.
Steps 1 to 4 are where a project's budget is quietly decided. The same thinking applies whether the result is an SPA, a multi-page app or something in between, which is why it is also how every project on our web app development page starts.
Choosing the tooling in 2026
There is no single right stack, but there are sensible defaults. These are the options we see most often, with the tradeoff each one carries. All of them are free and open source, so the cost sits in the build and the hosting, not in licences.
| Option | What you get | Good fit | Watch for |
|---|---|---|---|
| Vite with React, Vue or Svelte | A fast dev server and build. npm create vite@latest scaffolds from templates including vanilla, Vue, React, Preact, Lit, Svelte, Solid and Qwik | Logged-in tools and dashboards where nothing needs to be indexed | Routing, data fetching and rendering are yours to add. Vite currently requires Node.js 20.19+ or 22.12+ |
| React Router in SPA mode | Set ssr: false and the build produces one index.html that loads for any path, plus routing and data loading | React apps that may later need some server rendering | Per the React Router docs, code must still be safe to render at build time (no window on first render), and only the root route can have a server loader unless pages are pre-rendered |
| Next.js | Client and server rendering in one app, chosen per route. output: 'export' builds a static HTML file per route | Products with public pages in front of an app behind a login | Static export drops the server features, and a full Next.js app needs hosting that can run it |
| Nuxt (Vue) or SvelteKit | The same per-route mix of static, server and client rendering for those frameworks | Teams already working in Vue or Svelte | The same hosting question as Next.js |
| No framework | A small router, a few modules and the History API | One interactive tool inside an otherwise normal website | Anything bigger turns into a home-made framework nobody else can maintain |
The parts most tutorials skip
A tutorial ends when the counter goes up by one. A business app has to survive real users, real phones and the occasional bad actor. These are the gaps that cause the most trouble after launch.
Deep links that 404 on refresh
Inside the app, clicking through to /jobs/1042/ works. Paste that address into a new tab and the server looks for a file at that path, finds nothing, and returns an error. The fix is a fallback rule that sends unknown paths to the entry file. React Router's documentation gives the rewrite /* /index.html 200 and notes that some hosts do this by default. Cloudflare Pages is one of them: if it cannot find a static asset or a custom 404.html, it serves the root index.html. Which leads straight to the next problem.
Missing pages that look found
If every unknown path returns the app with a 200 status, a mistyped URL is a real page as far as Google is concerned, and Google treats it as a soft 404. Public routes should return a genuine 404 status, which is far easier when the server renders them.
Security that lives only in the interface
Hiding the Delete button from a staff account does not stop that account calling the delete endpoint directly. Every permission has to be checked on the server. Anything shipped in the JavaScript bundle, including keys, is readable by anyone who opens the browser's developer tools, so secret keys belong on the server only.
Accessibility on route changes
When a traditional page loads, a screen reader announces it and focus starts at the top. In an SPA nothing reloads, so unless the router updates the document title and moves focus to the new heading, a screen reader user may not know anything changed. In Ontario this is more than good practice: under the AODA, businesses and non-profits with 50 or more employees, and designated public sector organizations, must make public websites meet WCAG 2.0 Level AA.
Analytics that count one page view
Analytics tools traditionally record a page view when a page loads, and an SPA loads once. Google's guide to measuring single page applications says GA4's enhanced measurement can track page views from browser history events, with both page loads and history-based page changes switched on. It also warns against combining that with history tracking in Tag Manager, which double counts. Check DebugView before you trust the numbers.
Bundle size on a phone
An SPA feels fast after it loads. If the first load ships every screen's code at once, a customer on a mid-range phone with a weak signal waits for screens they will never open. Split the bundle by route, test on a real device, and watch the numbers in our Core Web Vitals guide.
When a single page application is the wrong choice
An SPA is a tool, not a goal. It suits work that happens behind a login: staff booking systems, customer portals, quoting tools and dashboards that people keep open all day. The smooth in-app navigation is the point, and nobody needs Google to index a customer's account screen.
It is the wrong default for:
- A business website. Service pages, location pages and articles exist to be found and to load instantly on any device. Normal pages do that for free.
- A store. Product and collection pages are search landing pages, and a platform like Shopify already handles rendering, checkout and payments. Rebuilding that is rarely worth it.
- A site with one interactive feature. A calculator, booking widget or configurator can sit on a normal page as a component. You do not need to turn the whole site into an app to get one interactive tool.
- A project nobody will maintain. SPAs depend on a chain of packages that need updating. An app without an owner ages faster than a plain website.
A single page application is also not the same thing as a one-page website, where every section sits on one long scrolling page. That is a design choice with its own limits, covered in what a one-page website can rank for. And if the real question is whether to build custom at all or rent a platform such as Bubble or Power Apps, start with low-code or custom development.
What it costs to have one built
We quote every project as a fixed price after a written scope, and projects start from $5,000. A single focused tool, such as a quoting calculator or an admin screen for an existing site, sits near that end. Cost climbs with the number of user types and permissions, the systems it connects to (accounting, CRM, e-commerce), whether it takes payments or holds sensitive information, and how much existing data has to come across. Hosting the front end of a client-rendered SPA can be very cheap, because it is static files. The API and database behind it are where the running costs live.
Before you sign with anyone, ask who owns the code and the data, how the public pages will be rendered, and what happens when something breaks on a weekend. Our questions for comparing website quotes work for app quotes too, and who owns your website covers the ownership side.
We build web apps and custom software for businesses across Ontario from our base in Brantford. If you are not sure whether you need an app or a better website, our custom software development team will tell you which one solves the problem, and if the answer is a website, that is our Brantford web design work.
The browser loads one HTML document and a JavaScript bundle once. After that, a router inside the app intercepts link clicks, changes the address with the browser History API, and redraws only the part of the screen that changed, fetching data from an API as it goes. The page never fully reloads, which is why a well-built SPA feels quick once it has loaded.
There is no single best one. React has the largest ecosystem, while Vue and Svelte are lighter to learn. The more useful question is whether any page needs to be found in search. If it does, pick a framework that can send finished HTML for those routes, such as Next.js, React Router, Nuxt or SvelteKit. For a tool that lives entirely behind a login, Vite with your framework of choice is a sensible, simple start.
Yes. A client-rendered SPA is just HTML, CSS and JavaScript files, so any static host can serve it, as long as unknown paths fall back to the entry file so deep links do not 404 on refresh. Cloudflare Pages does this by default when a project has no custom 404 page. The API and database the app talks to still need somewhere to run.
Not automatically, but they make it easy to get wrong. Google renders JavaScript in a second pass, and many AI crawlers do not run JavaScript at all. If a page should be found in search, send it as finished HTML from the server and keep client-side rendering for screens behind a login.