# Migrate from Next.js — Replace NEXT_PUBLIC_* with Runtime Config > Migrate from Next.js NEXT_PUBLIC_* build-time variables to REP runtime environment variables. Handles client-side code, SSR considerations, and automated codemod. Source: https://rep-protocol.dev/guides/migration/from-next/ > **Caution** > > REP is designed for **client-side** environment variables. Next.js server-side `process.env.*` (without `NEXT_PUBLIC_` prefix) should remain as-is — they're already server-only and don't need REP. ## Automated migration ```bash npx @rep-protocol/codemod --framework next src/ ``` ### What it transforms ```typescript // Before const apiUrl = process.env.NEXT_PUBLIC_API_URL; const flags = process.env.NEXT_PUBLIC_FEATURE_FLAGS; // After import { rep } from '@rep-protocol/sdk'; const apiUrl = rep.get('API_URL'); const flags = rep.get('FEATURE_FLAGS'); ``` Only `NEXT_PUBLIC_*` prefixed variables are transformed. Server-side `process.env.*` access is left unchanged. ### Preview first ```bash npx @rep-protocol/codemod --framework next --dry-run src/ ``` ## Manual migration 1. **Rename environment variables:** ```bash NEXT_PUBLIC_API_URL → REP_PUBLIC_API_URL NEXT_PUBLIC_ANALYTICS_KEY → REP_SENSITIVE_ANALYTICS_KEY ``` 2. **Update client-side code:** ```typescript import { rep } from '@rep-protocol/sdk'; const apiUrl = rep.get('API_URL', 'http://localhost:3000'); ``` 3. **Install the SDK:** ```bash npm install @rep-protocol/sdk ``` ## Post-migration cleanup 1. Remove `NEXT_PUBLIC_*` entries from `.env.local`, `.env.production`, etc. 2. Keep server-side `process.env.*` as-is (these are already server-only) 3. Run `rep typegen` for typed access 4. Update your Dockerfile to include the REP gateway > **Note** > > For Next.js static export (`next export` or `output: 'export'`), REP works like any other SPA. For SSR deployments, REP handles only the client-side variables — server-side config continues to use standard Node.js `process.env`.