Overview
FaunaDB is a serverless NoSQL document database that manages data globally with transactional consistency. It provides a flexible document model, allowing developers to store and query JSON-like data, and supports relationships through its temporal graph capabilities. The database is designed to scale horizontally and distribute data across multiple cloud regions, aiming to reduce latency for globally dispersed users. Its architecture supports strong consistency for all operations, including cross-region transactions, which is a distinguishing characteristic among globally distributed databases.
The platform is optimized for modern application development patterns, particularly serverless and JAMstack applications. Its serverless nature means that developers do not manage infrastructure or database servers; FaunaDB scales resources automatically based on demand. This approach aligns with the operational model of platforms like Render's web services or Vercel's Serverless Functions, where compute resources are ephemeral and billed based on usage. FaunaDB's usage-based pricing structure complements this, allowing developers to pay only for the reads, writes, and storage consumed by their applications.
FaunaDB offers a GraphQL API and a custom query language called FQL (Fauna Query Language). FQL provides a functional, expression-based syntax for performing complex data operations, including joins, aggregations, and temporal queries. The GraphQL API simplifies data fetching for client-side applications, enabling developers to define data requirements declaratively. This combination of APIs supports a range of application types, from real-time collaborative applications to e-commerce platforms and content management systems.
The database maintains a historical record of all data changes, enabling temporal queries and auditing capabilities. This allows developers to query data as it existed at a specific point in time or to track changes over time. This feature is useful for applications requiring data versioning, compliance auditing, or the ability to revert to previous states. FaunaDB's focus on transactional consistency and global distribution aims to address common challenges in building scalable, real-time applications without requiring complex sharding or multi-region replication configurations from the developer.
Key features
- Global Distribution and Replication: Data is automatically replicated across multiple cloud regions, offering low-latency access globally and ensuring high availability. Transactions maintain strong consistency across all replicas, including those in different regions.
- Serverless Architecture: FaunaDB operates as a fully managed service, eliminating the need for database provisioning, scaling, or maintenance. Resources adjust automatically to application demand.
- Transactional Consistency: Supports ACID-compliant transactions, including multi-document and cross-region transactions, ensuring data integrity even in distributed environments.
- Flexible Document Model: Stores data as JSON documents, providing schema flexibility that can adapt to evolving application requirements.
- GraphQL API: Provides a native GraphQL interface for querying and mutating data, simplifying client-side data access and reducing over-fetching or under-fetching of data.
- Fauna Query Language (FQL): A declarative, functional query language for advanced data manipulation, indexing, and security rules. FQL is used for defining schema, indexes, and business logic.
- Temporal Data Management: Maintains a history of all data changes, allowing developers to query data as it existed at any past point in time.
- Built-in Security: Offers role-based access control (RBAC) and supports integration with identity providers to secure data access. All data is encrypted at rest and in transit.
- Developer SDKs: Provides client libraries for JavaScript, Go, Python, Java, C#, and Ruby, facilitating integration with common programming languages and frameworks.
Pricing
FaunaDB uses a usage-based pricing model, with a free tier providing initial usage limits. Costs are calculated based on reads, writes, storage, and compute operations. The platform offers a free tier that resets monthly, allowing developers to build and test applications without immediate charges. Beyond the free tier, pricing scales linearly with usage.
| Service Component | Free Tier (Monthly) | Build Tier (Usage-Based) |
|---|---|---|
| Reads | 100,000 | $0.40 per 100,000 |
| Writes | 50,000 | $0.60 per 50,000 |
| Storage | 100 MB | $0.15 per GB |
| Compute Operations | 100,000 | $0.40 per 100,000 |
| Additional Cost Factors | N/A | Data transfer, streaming as of 2026-05-06 |
For high-volume applications or enterprise needs, custom pricing and dedicated plans are available upon request, which may include additional support and service level agreements. Further details are available on the FaunaDB pricing page.
Common integrations
- Serverless Functions: Integrates with platforms like AWS Lambda, Google Cloud Functions, and Azure Functions for backend logic.
- JAMstack Frameworks: Commonly used with frontend frameworks and static site generators such as React, Next.js, Gatsby, and Vue.js.
- GraphQL Clients: Works with various GraphQL client libraries like Apollo Client and Relay for simplified data management in frontend applications.
- Identity Providers: Can be integrated with authentication services like Auth0 or Firebase Authentication for user management and access control.
- API Gateways: Can be placed behind API gateways such as Amazon API Gateway or Google Cloud API Gateway to manage API access and security.
Alternatives
- Firebase: A Google-backed development platform offering a suite of services including a NoSQL document database (Cloud Firestore), authentication, and hosting. It is often chosen for mobile and web application backends.
- MongoDB Atlas: The cloud-native database service from MongoDB, providing a managed NoSQL document database with global distribution, scaling, and high availability features.
- PlanetScale: A serverless database platform built on Vitess, offering a MySQL-compatible experience with unlimited scaling and horizontal sharding. It focuses on developer experience and branch-based development workflows.
- CockroachDB: A distributed SQL database designed for high scalability and strong consistency, often considered for applications requiring relational database features with global distribution.
- Amazon DynamoDB: A fully managed NoSQL key-value and document database service offered by AWS, known for its high performance and scalability for internet-scale applications.
Getting started
To begin using FaunaDB, you will typically create a database, generate an API key, and then use one of the FaunaDB SDKs to interact with your data. The following example demonstrates how to connect to FaunaDB using the JavaScript SDK, create a collection, and insert a document.
import faunadb from 'faunadb';
const q = faunadb.query;
const client = new faunadb.Client({
secret: 'YOUR_FAUNADB_SECRET_KEY' // Replace with your actual key
});
async function setupAndCreateDocument() {
try {
// Create a collection if it doesn't exist
await client.query(
q.If(
q.Exists(q.Collection('users')),
true,
q.CreateCollection({ name: 'users' })
)
);
console.log('Collection "users" ensured.');
// Create a new document in the 'users' collection
const document = await client.query(
q.Create(
q.Collection('users'),
{
data: {
name: 'Alice Smith',
email: '[email protected]',
status: 'active'
}
}
)
);
console.log('Document created:', document.data);
// Retrieve the document by its ID
const retrievedDocument = await client.query(
q.Get(q.Ref(q.Collection('users'), document.ref.id))
);
console.log('Document retrieved:', retrievedDocument.data);
} catch (error) {
console.error('Error:', error);
}
}
setupAndCreateDocument();
Before running this code, ensure you have Node.js installed and the faunadb package in your project. You can install it via npm: npm install faunadb. Replace 'YOUR_FAUNADB_SECRET_KEY' with an actual server key obtained from your FaunaDB dashboard. This example demonstrates basic CRUD operations: creating a collection (if it doesn't exist), inserting a document, and then retrieving it. For more complex operations, developers can explore FQL's capabilities for indexing, relationships, and custom business logic.