---
title: Functions
slug: /functions
---

import { Check } from '@site/src/components/Check';

| Property / Characteristic | Reducers | Procedures | Views |
|---------------------------|----------|------------|-------|
| Read from tables | <Check /> | <Check /> | <Check /> |
| Write to tables | <Check /> | <Check /> | |
| Runs in transaction by default | <Check /> | | <Check /> |
| Atomic | <Check /> | (manual) | <Check /> |
| Deterministic | <Check /> | | <Check /> |
| External I/O (HTTP, etc.) | | <Check /> | |
| Side-effecting | | <Check /> | |
| Schedulable | <Check /> | <Check /> | |

SpacetimeDB modules can export three types of functions that clients can interact with:

## Reducers

**[Reducers](./00200-functions/00300-reducers/00300-reducers.md)** are functions that modify database state in response to client requests or system events. They are the primary way to mutate tables in SpacetimeDB. Reducers run inside database transactions, providing isolation, atomicity, and consistency guarantees. If a reducer fails, all changes are automatically rolled back.

Reducers are isolated and cannot interact with the outside world - they can only perform database operations. Use reducers for all state-changing operations in your module.

## Procedures

**[Procedures](./00200-functions/00400-procedures.md)** are functions similar to reducers, but with the ability to perform operations beyond the database. Unlike reducers, procedures can make HTTP requests to external services. However, procedures don't automatically run in database transactions - they must manually open and commit transactions to read from or modify database state.

Procedures are currently in beta and should only be used when you need their special capabilities, such as making HTTP requests. For standard database operations, prefer using reducers.

## Views

**[Views](./00200-functions/00500-views.md)** are read-only functions that compute and return results from your tables. Unlike reducers and procedures, views do not modify database state - they only query and return data. Views are useful for computing derived data, aggregations, or joining multiple tables server-side before sending results to clients.

Views run within a transaction to ensure isolation: the database state remains consistent for the entire duration of the view's execution. This means a view will never see partial updates from concurrent reducers.

Views can be subscribed to just like tables and will automatically update clients when underlying data changes, making them ideal for real-time computed data.
