# Configuration Guide
nchat is highly configurable through environment variables and the AppConfig system. This guide covers all configuration options.
## Table of Contents
- [Environment Variables](#environment-variables)
- [AppConfig System](#appconfig-system)
- [Backend Configuration](#backend-configuration)
- [Feature Configuration](#feature-configuration)
- [Theme Configuration](#theme-configuration)
- [Security Configuration](#security-configuration)
## Environment Variables
### Core Variables
| Variable | Required | Default | Description |
| ------------------------- | -------- | ------------- | -------------------------- |
| `NEXT_PUBLIC_GRAPHQL_URL` | Yes | - | Hasura GraphQL endpoint |
| `NEXT_PUBLIC_AUTH_URL` | Yes | - | Authentication service URL |
| `NEXT_PUBLIC_STORAGE_URL` | Yes | - | File storage service URL |
| `NEXT_PUBLIC_ENV` | No | `development` | Environment mode |
| `PORT` | No | `3000` | Server port |
### Authentication Variables
| Variable | Required | Default | Description |
| -------------------------- | -------- | ------- | ----------------------- |
| `NEXT_PUBLIC_USE_DEV_AUTH` | No | `false` | Enable development auth |
| `NEXTAUTH_SECRET` | Prod | - | NextAuth.js secret key |
| `NEXTAUTH_URL` | Prod | - | Application URL |
### OAuth Provider Variables
#### Google
| Variable | Description |
| ---------------------- | -------------------------- |
| `GOOGLE_CLIENT_ID` | Google OAuth client ID |
| `GOOGLE_CLIENT_SECRET` | Google OAuth client secret |
#### GitHub
| Variable | Description |
| ---------------------- | ----------------------- |
| `GITHUB_CLIENT_ID` | GitHub OAuth app ID |
| `GITHUB_CLIENT_SECRET` | GitHub OAuth app secret |
#### Apple
| Variable | Description |
| --------------------- | ------------------------- |
| `APPLE_CLIENT_ID` | Apple Services ID |
| `APPLE_CLIENT_SECRET` | Apple client secret (JWT) |
| `APPLE_TEAM_ID` | Apple Developer Team ID |
| `APPLE_KEY_ID` | Apple Sign-In key ID |
#### ID.me
| Variable | Description |
| -------------------- | ------------------------- |
| `IDME_CLIENT_ID` | ID.me OAuth client ID |
| `IDME_CLIENT_SECRET` | ID.me OAuth client secret |
| `IDME_SCOPE` | ID.me verification scopes |
### Branding Variables
| Variable | Required | Default | Description |
| --------------------------- | -------- | --------- | ------------------- |
| `NEXT_PUBLIC_APP_NAME` | No | `nchat` | Application name |
| `NEXT_PUBLIC_PRIMARY_COLOR` | No | `#6366f1` | Primary brand color |
| `NEXT_PUBLIC_LOGO_URL` | No | - | Logo image URL |
| `NEXT_PUBLIC_FAVICON_URL` | No | - | Favicon URL |
### Feature Variables
| Variable | Default | Description |
| ---------------------------------- | ------- | ---------------------- |
| `NEXT_PUBLIC_ENABLE_CHANNELS` | `true` | Enable channels |
| `NEXT_PUBLIC_ENABLE_DM` | `true` | Enable direct messages |
| `NEXT_PUBLIC_ENABLE_THREADS` | `true` | Enable threading |
| `NEXT_PUBLIC_ENABLE_REACTIONS` | `true` | Enable reactions |
| `NEXT_PUBLIC_ENABLE_FILE_UPLOADS` | `true` | Enable file uploads |
| `NEXT_PUBLIC_ENABLE_SEARCH` | `true` | Enable search |
| `NEXT_PUBLIC_ENABLE_NOTIFICATIONS` | `true` | Enable notifications |
### Example .env.local
```env
# Backend URLs
NEXT_PUBLIC_GRAPHQL_URL=http://api.localhost/v1/graphql
NEXT_PUBLIC_AUTH_URL=http://auth.localhost/v1/auth
NEXT_PUBLIC_STORAGE_URL=http://storage.localhost/v1/storage
# Environment
NEXT_PUBLIC_ENV=development
NEXT_PUBLIC_USE_DEV_AUTH=true
# Branding
NEXT_PUBLIC_APP_NAME=My Chat App
NEXT_PUBLIC_PRIMARY_COLOR=#0ea5e9
# Features
NEXT_PUBLIC_ENABLE_CHANNELS=true
NEXT_PUBLIC_ENABLE_DM=true
NEXT_PUBLIC_ENABLE_THREADS=true
```
## AppConfig System
The AppConfig system provides runtime configuration stored in the database.
### AppConfig Interface
```typescript
interface AppConfig {
setup: {
completed: boolean
completedSteps: string[]
currentStep: number
}
owner: {
name: string
email: string
company: string
role: string
}
branding: {
appName: string
logo: string | null
favicon: string | null
tagline: string
companyName: string
}
landing: {
mode: 'landing' | 'redirect' | 'chat'
heroTitle: string
heroSubtitle: string
showFeatures: boolean
showTestimonials: boolean
}
auth: {
methods: {
email: boolean
google: boolean
github: boolean
apple: boolean
idme: boolean
}
permissions: 'allow-all' | 'verified-only' | 'admin-only'
requireEmailVerification: boolean
allowRegistration: boolean
}
features: {
channels: boolean
directMessages: boolean
threads: boolean
reactions: boolean
fileUploads: boolean
voiceMessages: boolean
videoCall: boolean
screenShare: boolean
polls: boolean
reminders: boolean
search: boolean
notifications: boolean
bots: boolean
webhooks: boolean
}
theme: {
mode: 'light' | 'dark' | 'system'
preset: string
colors: {
primary: string
secondary: string
accent: string
background: string
foreground: string
}
}
integrations: {
slack: { enabled: boolean; webhookUrl?: string }
github: { enabled: boolean; token?: string }
jira: { enabled: boolean; domain?: string }
googleDrive: { enabled: boolean }
}
}
```
### Accessing AppConfig
```typescript
import { useAppConfig } from '@/contexts/app-config-context'
function MyComponent() {
const { config, updateConfig, isLoading } = useAppConfig()
if (isLoading) return
{config.branding.tagline}