From Vite
Automated migration
Section titled “Automated migration”npx @rep-protocol/codemod --framework vite src/What it transforms
Section titled “What it transforms”// Beforeconst apiUrl = import.meta.env.VITE_API_URL;const flags = import.meta.env.VITE_FEATURE_FLAGS;
// Afterimport { rep } from '@rep-protocol/sdk';const apiUrl = rep.get('API_URL');const flags = rep.get('FEATURE_FLAGS');What it leaves alone
Section titled “What it leaves alone”Vite built-in variables are not transformed:
import.meta.env.MODEimport.meta.env.DEVimport.meta.env.PRODimport.meta.env.SSRimport.meta.env.BASE_URL
Preview first
Section titled “Preview first”npx @rep-protocol/codemod --framework vite --dry-run src/Manual migration
Section titled “Manual migration”If you prefer to migrate manually:
-
Rename environment variables:
Terminal window VITE_API_URL → REP_PUBLIC_API_URLVITE_FEATURE_FLAGS → REP_PUBLIC_FEATURE_FLAGSVITE_ANALYTICS_KEY → REP_SENSITIVE_ANALYTICS_KEY -
Update code:
// Beforeconst apiUrl = import.meta.env.VITE_API_URL;// Afterimport { 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
vite-env.d.tsImportMetatype augmentations (if you had custom ones) - Remove
.env.productionand.env.stagingfiles from the project - Remove
envPrefixconfiguration fromvite.config.ts(if customized) - Run
rep typegen --manifest .rep.yaml --output src/rep.d.tsfor typed access - Update your Dockerfile to include the REP gateway