#spa and client side routing
3 messages · Page 1 of 1 (latest)
Hi @sand bough. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Astro does not natively support Single Page Application (SPA) mode as it primarily focuses on server-side rendering and delivering high-performance, content-focused websites. However, there is a community-contributed package called astro-spa that can be used to add SPA-like behavior to an Astro project.
To install and use the astro-spa package, you can follow these steps:
- Install the package using either
yarnornpm:
yarn add astro-spa
or
npm i astro-spa
- Import the
Spacomponent in your Astro file:
---
import { Spa } from 'astro-spa'
// or import Spa from 'astro-spa/Spa.astro'
---
<Spa/>
Please note that this package is not officially part of Astro and its usage might come with its own set of trade-offs. It's also worth noting that some community members have suggested that this functionality might be better suited as a separate library or waiting for the completion of the appHistory API (https://github.com/WICG/app-history).