# Hydration

## Enable Hydration

In `app.config.ts`:

```typescript
export const appConfig: ApplicationConfig = {
  providers: [provideClientHydration()],
};
```

## Browser-Only Code

Do not use `isPlatformBrowser`. Use Lifecycle hooks.

```typescript
@Component({...})
export class ChartComponent {
  constructor() {
    afterNextRender(() => {
      // Safe to use window/document here
      // This only runs on the browser
      new Chart(document.getElementById('chart'));
    });
  }
}
```

## Full App Config with Hydration and Transfer Cache

```typescript
// app.config.ts
export const appConfig: ApplicationConfig = {
  providers: [
    provideRouter(routes),
    provideClientHydration(withEventReplay()),
    provideHttpClient(withHttpTransferCacheOptions({ includePostRequests: false }))
  ]
};
```
