#spa and client side routing

3 messages · Page 1 of 1 (latest)

sand bough
#

is there an spa mode

uneven sequoiaBOT
#

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:

  1. Install the package using either yarn or npm:
yarn add astro-spa

or

npm i astro-spa
  1. Import the Spa component 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).

For more information, you can refer to the GitHub issue (https://github.com/withastro/astro/issues/1216) discussing the addition of an SPA component to Astro's built-in components.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: