From Next.js
Automated migration
Section titled “Automated migration”npx @rep-protocol/codemod --framework next src/What it transforms
Section titled “What it transforms”// Beforeconst apiUrl = process.env.NEXT_PUBLIC_API_URL;const flags = process.env.NEXT_PUBLIC_FEATURE_FLAGS;
// Afterimport { 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
Section titled “Preview first”npx @rep-protocol/codemod --framework next --dry-run src/Manual migration
Section titled “Manual migration”-
Rename environment variables:
Terminal window NEXT_PUBLIC_API_URL → REP_PUBLIC_API_URLNEXT_PUBLIC_ANALYTICS_KEY → REP_SENSITIVE_ANALYTICS_KEY -
Update client-side code:
import { rep } from '@rep-protocol/sdk';const apiUrl = rep.get('API_URL', 'http://localhost:3000'); -
Install the SDK:
Terminal window npm install @rep-protocol/sdk
Post-migration cleanup
Section titled “Post-migration cleanup”- Remove
NEXT_PUBLIC_*entries from.env.local,.env.production, etc. - Keep server-side
process.env.*as-is (these are already server-only) - Run
rep typegenfor typed access - Update your Dockerfile to include the REP gateway