# @izri/shared

> Common utilities, types, and environment configuration shared across all services

## Overview

The shared package provides core utilities, type definitions, and environment management used throughout the platform. It standardizes configuration access (server and browser) and should be used instead of direct process.env in Node services.

## Environment (env.ts)

Highlights:
- Universal access: import.meta.env in browser, process.env on server
- Loads root .env automatically via @dotenvx/dotenvx on server
- Type-safe getters with clear error messages
- Prefer using env from this package across all docs/examples

Common variables:
- API_URL, APP_URL
- DATABASE_URL
- BETTER_AUTH_SECRET
- OPENAI_API_KEY, ANTHROPIC_API_KEY
- GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET

Example:

```ts
import { env } from '@izri/shared'

if (env.IS_PRODUCTION) {
  // production-only logic
}

const apiUrl = env.API_URL
```

Note: Do not expose server-only secrets in browser code.

## Types and utils

- Id = string
- ApiResponse<T>
- Pagination
- assertDefined<T>(value, message)

## Best practices

- Frontend: only VITE_ prefixed vars are available; values are embedded at build time
- Backend: use env from this package; avoid direct process.env
- Keep secrets server-side only