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 (in which case you may want to combine this with Evidence's Cloud Execution Engine)

Comparison

Rendering Mode Static Site Generation Single Page App
Content Rendering Pre-rendered at build time Rendered on the client side
Page Generation Each page generated ahead of time Only one HTML file generated
Built Output All pages have corresponding HTML files Pages rendered using JavaScript
Build Duration Slower as builds all pages Faster as only one page is built
Performance Faster initial page loads Faster interactions after initial load
No Results

Enabling SPA Mode

SPA rendering mode is disabled by default.

To enable SPA rendering mode:

  1. Update the build command in package.json:
"build": "VITE_EVIDENCE_SPA=true evidence build"
  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 {
    preprocess: [],
    compilerOptions: {
        dev: true
    },
    kit: {
        adapter: adapter({
            fallback: 'index.html'
        })
    },
    vite: {
        server: {
            watch: {
            usePolling: true
            }
        }
    }
};