Skip to content

Commit e65e2ad

Browse files
j-patersonclaude
andauthored
Docs: Add quick reference for accessing SystemConfig (#1761)
Co-authored-by: Claude Opus 4.5 <[email protected]>
1 parent 91f7883 commit e65e2ad

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

docs/SYSTEMS/CONFIGURATION/ARCHITECTURE_OVERVIEW.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,49 @@
44

55
This document provides a comprehensive overview of the Nounspace configuration architecture. The system has been refactored from a static, build-time TypeScript-based configuration system to a **dynamic, database-backed, multi-tenant runtime configuration system** that supports domain-based community detection.
66

7+
## Quick Reference: Accessing SystemConfig
8+
9+
This is the most common question: "How do I access the system config?"
10+
11+
### Server Components
12+
13+
```typescript
14+
// ✅ Server components can load config directly
15+
import { loadSystemConfig } from "@/config";
16+
17+
export default async function MyServerComponent() {
18+
const systemConfig = await loadSystemConfig();
19+
return <ClientComponent systemConfig={systemConfig} />;
20+
}
21+
```
22+
23+
### Client Components
24+
25+
```typescript
26+
// ✅ Client components receive config as a prop
27+
"use client";
28+
29+
type Props = {
30+
systemConfig: SystemConfig;
31+
};
32+
33+
export function MyClientComponent({ systemConfig }: Props) {
34+
const discordUrl = systemConfig.community?.urls?.discord;
35+
// ...
36+
}
37+
```
38+
39+
### Pattern Summary
40+
41+
| Context | How to Access Config |
42+
|---------|---------------------|
43+
| Server Component | `await loadSystemConfig()` |
44+
| Client Component | Receive via `systemConfig` prop from parent |
45+
| API Route (pages/api) | `await loadSystemConfig()` |
46+
| App Router API Route | `await loadSystemConfig()` |
47+
48+
---
49+
750
## Core Architectural Principles
851

952
1. **Server-Only Config Loading**: `loadSystemConfig()` is server-only and uses `await headers()` API

0 commit comments

Comments
 (0)