> ## Documentation Index
> Fetch the complete documentation index at: https://twigz.arqqin.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Real-time Features

> Understanding real-time functionality in Twigz

# Real-time Features

Twigz is built on Convex, which provides powerful real-time capabilities out of the box.

## What Makes It Real-time?

### Live Data Updates

* **Orders**: Order status changes are instantly reflected across all connected clients
* **Inventory**: Product availability updates in real-time
* **Notifications**: Push notifications are delivered instantly
* **Cart**: Shopping cart changes sync across devices

### Real-time Subscriptions

```typescript theme={null}
// Subscribe to order updates
const orders = useQuery(api.customers.orders.getCustomerOrders, {
  customerId: "user_123"
});

// Subscribe to store dashboard
const dashboard = useQuery(api.stores.dashboard.getDashboardOverview, {
  storeId: "store_456"
});
```

## Key Real-time Features

### 1. **Live Order Tracking**

* Customers see order status updates instantly
* Store owners get real-time order notifications
* Delivery tracking with live updates

### 2. **Inventory Management**

* Stock levels update across all clients
* Out-of-stock notifications in real-time
* Automatic cart validation

### 3. **Social Features**

* Live feed updates
* Real-time likes and follows
* Instant messaging between users

### 4. **Admin Dashboard**

* Live analytics and metrics
* Real-time payout tracking
* Instant moderation tools

## Implementation

All Convex functions automatically provide real-time subscriptions. Simply use `useQuery` in your frontend to get live data updates.

```typescript theme={null}
// This automatically updates when data changes
const products = useQuery(api.shared.products.getProducts, {
  storeId: "store_123"
});
```

## Best Practices

1. **Optimize Queries**: Only subscribe to data you need
2. **Handle Loading States**: Always check for `undefined` during initial load
3. **Error Handling**: Implement proper error boundaries
4. **Performance**: Use pagination for large datasets

<Note>
  Real-time features work automatically with Convex - no additional setup required!
</Note>
