Skip to content

Commit de11338

Browse files
ci: apply automated fixes
1 parent a08b600 commit de11338

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

docs/router/framework/react/how-to/use-environment-variables.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -514,21 +514,22 @@ module.exports = {
514514

515515
**Solutions**:
516516

517-
1. **Add correct prefix**: Use `VITE_` for Vite, `PUBLIC_` for Rspack.
517+
1. **Add correct prefix**: Use `VITE_` for Vite, `PUBLIC_` for Rspack.
518518
Vite's default prefix may be changed in the config:
519519
```ts
520520
// vite.config.ts
521521
export const config = {
522522
// ...rest of your config
523-
envPrefix: 'MYPREFIX_' // this means `MYPREFIX_MY_VARIABLE` is the new correct way
523+
envPrefix: 'MYPREFIX_', // this means `MYPREFIX_MY_VARIABLE` is the new correct way
524524
}
525525
```
526-
3. **Restart development server** after adding new variables
527-
4. **Check file location**: `.env` file must be in project root
528-
5. **Verify bundler configuration**: Ensure variables are properly injected
529-
6. **Verify variable**:
530-
- **In dev**: is in correct `.env` file or environment
531-
- **For prod**: is in correct `.env` file or current environment ***at bundle time***. That's right, `VITE_`/`PUBLIC_`-prefixed variables are replaced in a macro-like fashion at bundle time, and will *never* be read at runtime on your server. This is a common mistake, so make sure this is not your case.
526+
2. **Restart development server** after adding new variables
527+
3. **Check file location**: `.env` file must be in project root
528+
4. **Verify bundler configuration**: Ensure variables are properly injected
529+
5. **Verify variable**:
530+
531+
- **In dev**: is in correct `.env` file or environment
532+
- **For prod**: is in correct `.env` file or current environment **_at bundle time_**. That's right, `VITE_`/`PUBLIC_`-prefixed variables are replaced in a macro-like fashion at bundle time, and will _never_ be read at runtime on your server. This is a common mistake, so make sure this is not your case.
532533

533534
**Example**:
534535

@@ -559,6 +560,7 @@ PUBLIC_API_KEY=abc123 npm run build
559560
**Solutions**:
560561

561562
Pass variables from the server down to the client:
563+
562564
1. Add your variable to the correct `env.` file
563565
2. Create an endpoint on your server to read the value from the client
564566

docs/start/framework/react/how-to/use-environment-variables.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,15 +378,16 @@ for (const key of requiredClientEnv) {
378378
// vite.config.ts
379379
export const config = {
380380
// ...rest of your config
381-
envPrefix: 'MYPREFIX_' // this means `MYPREFIX_MY_VARIABLE` is the new correct way
381+
envPrefix: 'MYPREFIX_', // this means `MYPREFIX_MY_VARIABLE` is the new correct way
382382
}
383383
```
384384
2. **Restart development server** after adding new variables
385385
3. **Check file location**: `.env` file must be in project root
386386
4. **Verify bundler configuration**: Ensure variables are properly injected
387387
5. **Verify variable**:
388-
- **In dev**: is in correct `.env` file or environment
389-
- **For prod**: is in correct `.env` file or current environment ***at bundle time***. That's right, `VITE_`-prefixed variables are replaced in a macro-like fashion at bundle time, and will *never* be read at runtime on your server. This is a common mistake, so make sure this is not your case.
388+
389+
- **In dev**: is in correct `.env` file or environment
390+
- **For prod**: is in correct `.env` file or current environment **_at bundle time_**. That's right, `VITE_`-prefixed variables are replaced in a macro-like fashion at bundle time, and will _never_ be read at runtime on your server. This is a common mistake, so make sure this is not your case.
390391

391392
**Example**:
392393

@@ -411,6 +412,7 @@ VITE_API_KEY=abc123 npm run build
411412
**Solutions**:
412413

413414
Pass variables from the server down to the client:
415+
414416
1. Add your variable to the correct `env.` file
415417
2. Create an endpoint on your server to read the value from the client
416418

0 commit comments

Comments
 (0)