CLI Reference
Commands
Options
Append flags with an extra --
after the command to modify behavior.
For example, npm run dev -- --port 4000
will start the development server on port 4000.
Some of the most common are:
Evidence's dev
and build
commands run using Vite, and so support Vite's options.
Evidence's preview
command runs using npx serve
and supports Serve's options
Environment Variables
You can set environment variables to configure Evidence in production. Most of these are used to set database credentials securely.
The format of environment variables for database credentials is EVIDENCE_SOURCE__[source_name]__[variable_name]
.
You can copy all your current environment variable values from the settings page at localhost:3000/settings.
N.B. Environment variables are case sensitive, so you should preserve the case specified in the settings page.
.env Files
Evidence will read in environment variables from a .env
file in the root of your project. This is useful for local development.
Environment Variables in Source Queries
Environment variables to be used in source queries should be prefixed with EVIDENCE_VAR__
(note the double underscore). They can be used in source queries with ${EVIDENCE_VAR__variable_name}
.
EVIDENCE_VAR__customer_name="Acme Corporation"
select *
from orders
where customer_name = '${customer_name}'
The quotes would be omitted if the variable was not a string.
Environment Variables in Pages
Environment variables to be used in pages should be prefixed with VITE_
. They can be accessed with import.meta.env.VITE_variable_name
.
.env
VITE_customer_attribute=premium
index.md
<script>
const customer_attribute = import.meta.env.VITE_customer_attribute;
</script>
{#if customer_attribute === 'premium'}
Premium content
{:else if customer_attribute === 'free'}
Free content
{/if}