Constants Reference
Application-wide constants are organized across several files under lib/constants/ and the root lib/constants.ts. This page documents every exported constant grouped by domain.
File Structure
lib/
constants.ts # Main constants file (localization, branding, API, auth, analytics)
constants/
analytics.ts # Viewer tracking constants
payment.ts # Payment enums, plan names, pricing
The root constants.ts re-exports values from the subdirectory files for backward compatibility.
Localization
Defined in lib/constants.ts.
export const DEFAULT_LOCALE = 'en';
export const LOCALES = [
'en', 'fr', 'es', 'de', 'zh', 'ar', 'he', 'ru', 'uk',
'pt', 'it', 'ja', 'ko', 'nl', 'pl', 'tr', 'vi', 'th',
'hi', 'id', 'bg',
] as const;
export type Locale = (typeof LOCALES)[number];
/** Locales that use right-to-left text direction */
export const RTL_LOCALES: readonly Locale[] = ['ar', 'he'] as const;
The LOCALES tuple drives route generation, i18n configuration, and hreflang tag generation across the template.
Branding and UI
export const LOGO_URL = '/logo-ever-work-3.png';
API and Backend
// Base URL for internal website API (Next.js API routes)
export const API_BASE_URL = getNextPublicEnv('NEXT_PUBLIC_API_BASE_URL');
For the Ever Works Platform API, use the PLATFORM_API_URL and PLATFORM_API_SECRET_TOKEN environment variables instead. See the API Client Layer documentation.
Authentication and Security
export const COOKIE_SECRET = getNextPublicEnv('COOKIE_SECRET');
export const JWT_ACCESS_TOKEN_EXPIRES_IN = getNextPublicEnv('JWT_ACCESS_TOKEN_EXPIRES_IN');
export const JWT_REFRESH_TOKEN_EXPIRES_IN = getNextPublicEnv('JWT_REFRESH_TOKEN_EXPIRES_IN');
Analytics - PostHog
export const POSTHOG_KEY = getNextPublicEnv('NEXT_PUBLIC_POSTHOG_KEY');
export const POSTHOG_HOST = getNextPublicEnv('NEXT_PUBLIC_POSTHOG_HOST');
export const POSTHOG_ENABLED = POSTHOG_KEY?.value && POSTHOG_HOST?.value;
export const POSTHOG_DEBUG = getNextPublicEnv('POSTHOG_DEBUG');
// Feature toggles
export const POSTHOG_SESSION_RECORDING_ENABLED = getNextPublicEnv(
'POSTHOG_SESSION_RECORDING_ENABLED', 'true'
);
export const POSTHOG_AUTO_CAPTURE = getNextPublicEnv('POSTHOG_AUTO_CAPTURE', 'false');
// Sampling rates (lower in production to reduce data volume)
export const POSTHOG_SAMPLE_RATE = clientEnv.isProduction ? 0.1 : 1.0;
export const POSTHOG_SESSION_RECORDING_SAMPLE_RATE = clientEnv.isProduction ? 0.1 : 1.0;
Error Tracking - Sentry
export const SENTRY_DSN = getNextPublicEnv('NEXT_PUBLIC_SENTRY_DSN');
export const SENTRY_ENABLE_DEV = getNextPublicEnv('SENTRY_ENABLE_DEV');
export const SENTRY_DEBUG = getNextPublicEnv('SENTRY_DEBUG');
export const SENTRY_ENABLED =
SENTRY_DSN?.value && (SENTRY_ENABLE_DEV?.value === 'true' || clientEnv.isProduction);
Exception Tracking - Unified
export const EXCEPTION_TRACKING_PROVIDER = getNextPublicEnv(
'EXCEPTION_TRACKING_PROVIDER', 'both'
);
export const POSTHOG_EXCEPTION_TRACKING = getNextPublicEnv(
'POSTHOG_EXCEPTION_TRACKING', 'true'
);
export const SENTRY_EXCEPTION_TRACKING = getNextPublicEnv(
'SENTRY_EXCEPTION_TRACKING', 'true'
);
type ExceptionTrackingProvider = 'sentry' | 'posthog' | 'both' | 'none';
ReCAPTCHA
export const RECAPTCHA_SITE_KEY = getNextPublicEnv('NEXT_PUBLIC_RECAPTCHA_SITE_KEY');
export const RECAPTCHA_SECRET_KEY = getNextPublicEnv('RECAPTCHA_SECRET_KEY');
Analytics Constants (constants/analytics.ts)
/** Cookie name for storing the anonymous viewer ID */
export const VIEWER_COOKIE_NAME = 'ever_viewer_id';
/** Cookie max age in seconds (365 days) */
export const VIEWER_COOKIE_MAX_AGE = 365 * 24 * 60 * 60;
These constants drive unique daily view tracking without requiring authentication.
Payment Constants (constants/payment.ts)
This file is intentionally separated from the main constants.ts so it can be imported in scripts that run outside the Next.js runtime (migrations, seeds, etc.).
Payment Flow
enum PaymentFlow {
PAY_AT_START = 'pay_at_start',
PAY_AT_END = 'pay_at_end',
}
Payment Status
enum PaymentStatus {
PENDING = 'pending',
PAID = 'paid',
FAILED = 'failed',
}
Payment Interval
enum PaymentInterval {
DAILY = 'daily',
WEEKLY = 'weekly',
MONTHLY = 'monthly',
YEARLY = 'yearly',
ONE_TIME = 'one-time',
PER_SUBMISSION = 'per-submission',
}
Payment Plans
enum PaymentPlan {
FREE = 'free',
STANDARD = 'standard',
PREMIUM = 'premium',
}
const PAYMENT_PLAN_NAMES: Record<PaymentPlan, string> = {
[PaymentPlan.FREE]: 'Free Plan',
[PaymentPlan.STANDARD]: 'Standard Plan',
[PaymentPlan.PREMIUM]: 'Premium Plan',
};
Payment Method
enum PaymentMethod {
CREDIT_CARD = 'credit_card',
PAYPAL = 'paypal',
}
Payment Currency
enum PaymentCurrency {
USD = 'USD',
EUR = 'EUR',
GBP = 'GBP',
CAD = 'CAD',
AUD = 'AUD',
ETH = 'ETH',
}
Payment Provider
enum PaymentProvider {
STRIPE = 'stripe',
SOLIDGATE = 'solidgate',
LEMONSQUEEZY = 'lemonsqueezy',
POLAR = 'polar',
}
Submission Status
enum SubmissionStatus {
DRAFT = 'draft',
PENDING = 'pending',
APPROVED = 'approved',
REJECTED = 'rejected',
PUBLISHED = 'published',
ARCHIVED = 'archived',
}
Sponsor Ad Pricing
const SponsorAdPricing = {
WEEKLY: 100, // $100.00
MONTHLY: 300, // $300.00
} as const;
These are default fallback values. Runtime values are controlled by the settings system via getSponsorAdWeeklyPrice() and getSponsorAdMonthlyPrice().
Import Patterns
// Import from the main constants file
import { DEFAULT_LOCALE, LOCALES, PaymentPlan, SubmissionStatus } from '@/lib/constants';
// Import payment constants directly (for scripts outside Next.js)
import { PaymentPlan, PaymentProvider } from '@/lib/constants/payment';
// Import analytics constants directly
import { VIEWER_COOKIE_NAME, VIEWER_COOKIE_MAX_AGE } from '@/lib/constants/analytics';
Related Files
lib/constants.ts- Main constants file with re-exportslib/constants/analytics.ts- Viewer tracking constantslib/constants/payment.ts- Payment enums and pricing defaultslib/config/- Runtime configuration (environment-based)