Rendering Modes

Evidence supports two rendering modes:

  1. Static Site Generation (Default)
  2. Single Page App (SPA)

Choosing a Rendering Mode

You should generally only use the SPA rendering mode if one of the following is true:

  • You have a large number of pages, >1000+ is a good rule of thumb
  • You want to update your data frequently, so short build times are desirable
  • Your data sources are large

Comparison

No Results

Enabling SPA Mode

SPA rendering mode is disabled by default.

To enable SPA rendering mode:

  1. Update the build and preview scripts in package.json:
"build": "VITE_EVIDENCE_SPA=true evidence build",
"preview": "VITE_EVIDENCE_SPA=true evidence preview",
  1. Add svelte adapter-static as a dev dependency:
npm install --save-dev @sveltejs/adapter-static
  1. Add a svelte.config.js file to the root of your project containing the following:
import adapter from '@sveltejs/adapter-static';

/** @type {import("@sveltejs/kit").Config} */
export default {
    kit: {
        adapter: adapter({
            fallback: 'index.html'
        })
    },
};
  1. If self-hosting an SPA it is important to redirect all URLs to index.html. For example in an NGINX server block you would put:
root /path/to/your/project/build/;

location / {
    try_files $uri $uri/ $uri.html /index.html;
}