Rendering Modes
Evidence supports two rendering modes:
- Static Site Generation (Default)
- 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
No Results
Enabling SPA Mode
Note: To deploy an SPA mode app on Evidence Cloud, you currently need to deploy on a private site, using the Cloud Execution Engine.
SPA rendering mode is disabled by default.
To enable SPA rendering mode:
- Update the build and preview scripts in
package.json
:
"build": "VITE_EVIDENCE_SPA=true evidence build",
"preview": "VITE_EVIDENCE_SPA=true evidence preview",
- Add svelte adapter-static as a dev dependency:
npm install --save-dev @sveltejs/adapter-static
- 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'
})
},
};
- 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;
}