Configuration
AnimeThemes Web uses environment variables to configure API endpoints, build behavior, and feature flags. This guide covers all available configuration options.Environment Files
Next.js supports multiple environment files for different stages:.env.local- Local development (not committed to git).env.development- Development environment.env.production- Production environment.env- Default for all environments
For local development, create a
.env.local file in the root directory. This file is ignored by git and won’t be committed to version control.Minimal Setup
The absolute minimum configuration requires only one environment variable:.env.local
Server-Side Variables
These variables are only available on the server-side (during build and SSR):The URL to the AnimeThemes API which will be used on the server.Example:
This is required if
NEXT_PUBLIC_API_URL is not set. At least one API URL must be configured.Activate minimal build mode. In minimal build mode, only a small subset of pages get prerendered at build time, significantly reducing build time.Example:
Activate the Next.js bundle analyzer. This generates an interactive treemap visualization of the bundle size.Example:When enabled, run:The analyzer will open in your browser after the build completes.
Custom referer header for authentication requests.Example:
Client-Side Variables
These variables are exposed to the browser (prefixed withNEXT_PUBLIC_):
The URL to the AnimeThemes API which will be used in the browser.Example:
The URL from which video files should be served.Example:
The URL from which audio files should be served.Example:
The path to use for authentication API requests. It will be appended to
NEXT_PUBLIC_API_URL.Example:This is fine to leave unset for development, but should be configured in production.
The base path the app should be hosted on. Useful if deploying to a subdirectory.Example:This would make the app available at
https://example.com/wiki instead of https://example.com.Activate staging mode. In staging mode, a warning banner is displayed at the top of the page indicating this is a test environment.Example:When enabled, users will see a prominent warning that they’re on a staging site.
Enable verbose logging for debugging purposes.Example:
Set the page size to fetch when resolving paginated resources.Example:
If not set, the default value of 25 will be used.
Complete Configuration Example
Here’s a complete.env.local file with all available options:
.env.local
Configuration Validation
AnimeThemes Web validates your configuration on startup. The validation checks:Required Variables
At least one of
ANIMETHEMES_API_URL or NEXT_PUBLIC_API_URL must be set.If neither is set, the application will exit with an error.src/utils/config.ts:28.
TypeScript Configuration
The project uses TypeScript with strict mode enabled. Key settings:tsconfig.json
The
@/* path alias resolves to the src directory, allowing clean imports like @/components/Button.Next.js Configuration
The project uses a TypeScript-based Next.js config (next.config.ts) with these key settings:
Base Path
Configured viaNEXT_PUBLIC_BASE_PATH environment variable. Useful for subdirectory deployments.
Styled Components
Server-side rendering for styled-components is enabled:Security Headers
The following security headers are automatically added:X-DNS-Prefetch-Control: onStrict-Transport-SecurityX-XSS-ProtectionX-Frame-Options: SAMEORIGINX-Content-Type-Options: nosniffReferrer-Policy: origin-when-cross-origin
Static Generation Timeout
Set to 3600 seconds (1 hour) for complex page generation:URL Redirects
Automatic redirects are configured:/wiki/blog/:slug*→/blog/:slug*/wiki/status/:slug*→/blog/status_:slug*
Common Configuration Scenarios
Local Development
Local Development
.env.local
Production Deployment
Production Deployment
.env.production
Staging Environment
Staging Environment
.env.staging
Subdirectory Deployment
Subdirectory Deployment
.env.production
https://yourdomain.com/wiki.Next Steps
Development
Learn about the development workflow and available commands
Next.js Environment Variables
Read the official Next.js documentation on environment variables