title: Data & Configuration page: data

Data & Configuration

Access environment variables, the built-in data store, and server configuration directly from your templates.

Environment Variables

Use #env.VAR_NAME# in templates to access any environment variable set on the server. Great for API keys, feature flags, and configuration.

RUST_LOG: #env.RUST_LOG#
USER: #env.USER#
HOME: #env.HOME#
SHELL: #env.SHELL#

Variables that are not set will render as empty strings. Set them when starting the server to make them available.

Data Store

The built-in DataStore uses a JSON format with collections and values. Define data files in your project and access them via template variables.

DataStore JSON Format
{
"collections": {
"items": [ ... ]
},
"values": {}
}

Collections hold arrays of objects. Values hold simple key-value pairs. Both are accessible in templates for rendering lists, tables, and dynamic content.

Current Application Data
App Counter: #data.application.app_counter#

Planned Enhancements

Database Adapters

Connect to SQLite or PostgreSQL via [database] config. Same DataStore interface, real database backend.

Collection Queries

Query local data with sort, filter, search, limit, and offset using the local: fetch prefix.

REST API Generation

Auto-generate JSON API endpoints from your data collections via [api] config.

Template Filters

Transform values with |uppercase, |truncate:N, |date:fmt, |currency, and |markdown.

Configuration

Server configuration is defined in wwwhat.toml at your project root. It controls sessions, caching, data sources, and more.

Sessions
  • Cookie-based session IDs
  • SQLite persistence
  • Configurable expiration
  • HttpOnly, SameSite cookies
Caching
  • Page-level caching
  • Data store caching
  • External API response caching
  • Automatic invalidation
Data Sources
  • JSON file collections
  • Application-wide state
  • Per-session state
  • CRUD via w-action endpoints
Directory Config
  • application.what files
  • Parent-to-child inheritance
  • Layout assignment
  • Auth and data exposure