Configuration
Complete guide to SDK configuration options for different environments and use cases.
Basic Configuration
Section titled “Basic Configuration”Minimum Required Config
Section titled “Minimum Required Config”import { AetherSDK } from '@aether-official/sites-sdk';
const sdk = new AetherSDK({ siteId: 'your-site-id', organizationId: 'your-org-id', editorOrigin: 'https://app.aether.com',});Recommended Config
Section titled “Recommended Config”const sdk = new AetherSDK({ siteId: process.env.PUBLIC_AETHER_SITE_ID, organizationId: process.env.PUBLIC_AETHER_ORG_ID, editorOrigin: process.env.PUBLIC_AETHER_EDITOR_URL, debug: process.env.NODE_ENV === 'development', autoInit: true,});Configuration Options
Section titled “Configuration Options”siteId (required)
Section titled “siteId (required)”Your site’s unique identifier from Aether.
Type: string
Example: 'clqx1234abcd5678efgh'
Where to find:
- Navigate to Sites in Aether
- Click your site
- Copy the Site ID from settings
organizationId (required)
Section titled “organizationId (required)”Your organization’s unique identifier.
Type: string
Example: 'org_abc123xyz789'
Where to find:
- Open your organization settings
- Copy the Organization ID
editorOrigin (required)
Section titled “editorOrigin (required)”The origin URL of the Aether editor for postMessage security.
Type: string
Default: None
Example: 'https://app.aether.com'
Common values:
- Production:
'https://app.aether.com' - Staging:
'https://staging.aether.com' - Local development:
'http://localhost:3000'
debug (optional)
Section titled “debug (optional)”Enable verbose console logging.
Type: boolean
Default: false
Example: true
When to use:
- Development: Enable to see SDK lifecycle events
- Production: Disable to reduce console noise
debug: process.env.NODE_ENV === 'development'editableSelector (optional)
Section titled “editableSelector (optional)”Custom CSS selector for editable elements.
Type: string
Default: '[data-aether-field]'
Example: '[data-edit]'
When to use:
- Custom attribute names
- Avoiding conflicts with other libraries
editableSelector: '[data-cms-field]'autoInit (optional)
Section titled “autoInit (optional)”Automatically initialize SDK on construction.
Type: boolean
Default: true
Example: false
When to set false:
- Manual initialization control
- Conditional initialization
const sdk = new AetherSDK({ ...config, autoInit: false,});
// Later, when readyawait sdk.initialize();Environment-Specific Configs
Section titled “Environment-Specific Configs”Development
Section titled “Development”PUBLIC_AETHER_SITE_ID=test-site-devPUBLIC_AETHER_ORG_ID=test-org-devPUBLIC_AETHER_EDITOR_URL=http://localhost:3000AETHER_API_URL=http://localhost:3000/api/trpcconst sdk = new AetherSDK({ siteId: import.meta.env.PUBLIC_AETHER_SITE_ID, organizationId: import.meta.env.PUBLIC_AETHER_ORG_ID, editorOrigin: import.meta.env.PUBLIC_AETHER_EDITOR_URL, debug: true, // Always true in development});Staging
Section titled “Staging”PUBLIC_AETHER_SITE_ID=staging-site-idPUBLIC_AETHER_ORG_ID=staging-org-idPUBLIC_AETHER_EDITOR_URL=https://staging.aether.comAETHER_API_URL=https://staging.aether.com/api/trpcProduction
Section titled “Production”PUBLIC_AETHER_SITE_ID=prod-site-idPUBLIC_AETHER_ORG_ID=prod-org-idPUBLIC_AETHER_EDITOR_URL=https://app.aether.comAETHER_API_URL=https://app.aether.com/api/trpcAETHER_API_TOKEN=aether_prod_token_xxxxxconst sdk = new AetherSDK({ siteId: import.meta.env.PUBLIC_AETHER_SITE_ID, organizationId: import.meta.env.PUBLIC_AETHER_ORG_ID, editorOrigin: import.meta.env.PUBLIC_AETHER_EDITOR_URL, debug: false, // Never true in production});Content Fetching Config
Section titled “Content Fetching Config”Server-Side Config
Section titled “Server-Side Config”import { fetchSection } from '@aether-official/sites-sdk';
const config = { apiUrl: process.env.AETHER_API_URL, apiToken: process.env.AETHER_API_TOKEN,};
const section = await fetchSection('hero-123', config);Client-Side Config with Caching
Section titled “Client-Side Config with Caching”import { createContentManager } from '@aether-official/sites-sdk';
const content = createContentManager({ apiUrl: 'https://app.aether.com/api/trpc', apiToken: process.env.AETHER_API_TOKEN,
// Cache configuration cacheTTL: 5 * 60 * 1000, // 5 minutes cacheEnabled: true,
// Debug debug: false,});Astro Build-Time Config
Section titled “Astro Build-Time Config”---import { getConfig } from '@aether-official/sites-sdk/astro';
// Auto-extracts from environmentconst config = getConfig(import.meta.env);
// Manual configconst manualConfig = { apiUrl: import.meta.env.AETHER_API_URL, apiToken: import.meta.env.AETHER_API_TOKEN, siteId: import.meta.env.PUBLIC_AETHER_SITE_ID, organizationId: import.meta.env.PUBLIC_AETHER_ORG_ID,};---Framework-Specific Configs
Section titled “Framework-Specific Configs”Astro Integration Config
Section titled “Astro Integration Config”The Astro integration accepts additional configuration options:
import { defineConfig } from 'astro/config';import aetherSites from '@aether-official/sites-sdk/astro';
export default defineConfig({ integrations: [ aetherSites({ // Required siteId: process.env.PUBLIC_AETHER_SITE_ID || process.env.AETHER_SITE_ID, organizationId: process.env.PUBLIC_AETHER_ORGANIZATION_ID || process.env.AETHER_ORGANIZATION_ID, editorOrigin: process.env.PUBLIC_AETHER_EDITOR_ORIGIN || 'http://localhost:3000',
// Optional enabled: process.env.PUBLIC_AETHER_EDITOR_ENABLED === 'true' || true, debug: process.env.NODE_ENV === 'development', autoMiddleware: true, }) ],});enabled (optional)
Section titled “enabled (optional)”Enable or disable the SDK integration entirely.
Type: boolean
Default: true
Example: process.env.PUBLIC_AETHER_EDITOR_ENABLED === 'true'
When to use:
- Conditionally enable SDK based on environment
- Disable for production builds if not needed
- Feature flag for gradual rollout
// Only enable in development and stagingenabled: process.env.NODE_ENV !== 'production'
// Enable via environment variableenabled: process.env.PUBLIC_AETHER_EDITOR_ENABLED === 'true'autoMiddleware (optional)
Section titled “autoMiddleware (optional)”Automatically inject middleware for CSP headers and visual editor support.
Type: boolean
Default: true
Example: true
When to set false:
- Custom middleware configuration needed
- Manual control over middleware order
- Using custom CSP headers
// Disable auto-middleware for custom setupautoMiddleware: falseIf disabled, manually create src/middleware.ts:
import { onRequest as aetherMiddleware } from '@aether-official/sites-sdk/middleware';
export const onRequest = aetherMiddleware;debug (optional)
Section titled “debug (optional)”Enable verbose SDK logging.
Type: boolean
Default: false
Example: process.env.NODE_ENV === 'development'
Recommended pattern:
// Auto-enable in developmentdebug: process.env.NODE_ENV === 'development'Complete Astro Example
Section titled “Complete Astro Example”import { defineConfig } from 'astro/config';import aetherSites from '@aether-official/sites-sdk/astro';
export default defineConfig({ integrations: [ aetherSites({ // Required - fallback from both public and private env vars siteId: process.env.PUBLIC_AETHER_SITE_ID || process.env.AETHER_SITE_ID, organizationId: process.env.PUBLIC_AETHER_ORGANIZATION_ID || process.env.AETHER_ORGANIZATION_ID, editorOrigin: process.env.PUBLIC_AETHER_EDITOR_ORIGIN || 'http://localhost:3000',
// Optional - enable based on environment variable or default to true enabled: process.env.PUBLIC_AETHER_EDITOR_ENABLED === 'true' || true,
// Optional - debug in development only debug: process.env.NODE_ENV === 'development',
// Optional - auto-inject middleware (recommended) autoMiddleware: true, }) ],
vite: { define: { 'import.meta.env.PUBLIC_AETHER_SITE_ID': JSON.stringify( process.env.PUBLIC_AETHER_SITE_ID ), }, },});Next.js
Section titled “Next.js”module.exports = { env: { NEXT_PUBLIC_AETHER_SITE_ID: process.env.NEXT_PUBLIC_AETHER_SITE_ID, NEXT_PUBLIC_AETHER_ORG_ID: process.env.NEXT_PUBLIC_AETHER_ORG_ID, NEXT_PUBLIC_AETHER_EDITOR_URL: process.env.NEXT_PUBLIC_AETHER_EDITOR_URL, },};export default { define: { 'import.meta.env.PUBLIC_AETHER_SITE_ID': JSON.stringify( process.env.PUBLIC_AETHER_SITE_ID ), },};Security Best Practices
Section titled “Security Best Practices”Environment Variables
Section titled “Environment Variables”# ✅ Good - Separate public and privatePUBLIC_AETHER_SITE_ID=site-123 # Exposed to browserAETHER_API_TOKEN=aether_secret_xxx # Server-only
# ❌ Bad - Exposing secretsPUBLIC_AETHER_API_TOKEN=xxx # Never make tokens public!Token Management
Section titled “Token Management”// ✅ Server-side onlyconst serverConfig = { apiUrl: process.env.AETHER_API_URL, apiToken: process.env.AETHER_API_TOKEN, // Not exposed to browser};
// ❌ Never in client-side codeconst clientConfig = { apiToken: 'aether_token_xxx', // Exposed in browser!};Origin Validation
Section titled “Origin Validation”// ✅ Strict origin matchingeditorOrigin: 'https://app.aether.com'
// ❌ Wildcards or multiple origins not supportededitorOrigin: '*' // Not allowedTroubleshooting
Section titled “Troubleshooting””SDK not initializing”
Section titled “”SDK not initializing””Cause: Missing or incorrect configuration
Solution:
// Check all required fields are presentconst sdk = new AetherSDK({ siteId: process.env.PUBLIC_AETHER_SITE_ID, // ✅ Required organizationId: process.env.PUBLIC_AETHER_ORG_ID, // ✅ Required editorOrigin: process.env.PUBLIC_AETHER_EDITOR_URL, // ✅ Required debug: true, // Enable logging to see errors});“PostMessage origin mismatch”
Section titled ““PostMessage origin mismatch””Cause: editorOrigin doesn’t match actual editor URL
Solution:
// Must match exactly (including protocol and port)editorOrigin: 'https://app.aether.com' // Not http or www“API token invalid”
Section titled ““API token invalid””Cause: Token not set or expired
Solution:
- Regenerate token in Aether dashboard
- Update environment variable
- Restart development server
Validation
Section titled “Validation”Config Validator
Section titled “Config Validator”import { AetherSDK } from '@aether-official/sites-sdk';
function validateConfig(config: any): boolean { const required = ['siteId', 'organizationId', 'editorOrigin'];
for (const field of required) { if (!config[field]) { console.error(`Missing required field: ${field}`); return false; } }
// Validate editorOrigin format try { new URL(config.editorOrigin); } catch { console.error('Invalid editorOrigin URL'); return false; }
return true;}
const config = { siteId: process.env.PUBLIC_AETHER_SITE_ID, organizationId: process.env.PUBLIC_AETHER_ORG_ID, editorOrigin: process.env.PUBLIC_AETHER_EDITOR_URL,};
if (validateConfig(config)) { const sdk = new AetherSDK(config);}Advanced Configuration
Section titled “Advanced Configuration”Custom Event Handlers
Section titled “Custom Event Handlers”const sdk = new AetherSDK(config);
// Custom ready handlersdk.on('ready', () => { console.log('SDK ready - custom initialization'); // Custom setup logic});
// Error handlersdk.on('error', (error) => { // Send to error tracking service console.error('SDK Error:', error);});Conditional Initialization
Section titled “Conditional Initialization”// Only initialize in editor modeconst params = new URLSearchParams(window.location.search);const isEditorMode = params.get('aether-editor') === 'true';
if (isEditorMode) { const sdk = new AetherSDK({ siteId: import.meta.env.PUBLIC_AETHER_SITE_ID, organizationId: import.meta.env.PUBLIC_AETHER_ORG_ID, editorOrigin: import.meta.env.PUBLIC_AETHER_EDITOR_URL, });}Next Steps
Section titled “Next Steps”- Content Fetching - Fetch content from Aether
- Visual Editor - Enable inline editing
- Astro Integration - Complete Astro guide