Environment Variables

Smallweb provides several built-in environment variables and supports custom configuration.

Built-in Variables

These variables are automatically available in every app:

Variable Description
SMALLWEB_DIR Path to the Smallweb directory
SMALLWEB_DOMAIN The base domain (e.g., polkmojo.com)
SMALLWEB_APP_NAME Name of the current app
SMALLWEB_APP_URL Full URL of the current app

Using Environment Variables

Access them in your main.ts:

export default {
    fetch: (request: Request) => {
        const { SMALLWEB_DOMAIN, SMALLWEB_APP_NAME } = Deno.env.toObject();
        
        return new Response(`Running on ${SMALLWEB_APP_NAME}.${SMALLWEB_DOMAIN}`);
    }
}

Custom Variables

You can set custom environment variables in your Smallweb configuration file.