From Create React App
Automated migration
Section titled “Automated migration”npx @rep-protocol/codemod --framework cra src/What it transforms
Section titled “What it transforms”// Beforeconst apiUrl = process.env.REACT_APP_API_URL;const flags = process.env.REACT_APP_FEATURE_FLAGS;
// Afterimport { rep } from '@rep-protocol/sdk';const apiUrl = rep.get('API_URL');const flags = rep.get('FEATURE_FLAGS');Only REACT_APP_* prefixed variables are transformed. Other process.env.* access is left unchanged.
Preview first
Section titled “Preview first”npx @rep-protocol/codemod --framework cra --dry-run src/Manual migration
Section titled “Manual migration”-
Rename environment variables:
Terminal window REACT_APP_API_URL → REP_PUBLIC_API_URLREACT_APP_ANALYTICS_KEY → REP_SENSITIVE_ANALYTICS_KEY -
Update 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
react-app-env.d.ts(CRA’s auto-generated type declarations) - Remove
.env.productionand.env.stagingfiles - Run
rep typegenfor typed access - Update your Dockerfile to include the REP gateway