DEV Community

Alex Spinov
Alex Spinov

Posted on

Xata Has a Free Serverless Database — PostgreSQL With Built-in Search, Analytics, and AI

What if your database had built-in full-text search, vector embeddings, file storage, and analytics — without adding Elasticsearch, Pinecone, S3, and a data warehouse?

What is Xata?

Xata is a serverless database platform built on PostgreSQL and Elasticsearch. It combines a relational database with full-text search, vector search, file attachments, and analytics in one API.

Why Xata

1. PostgreSQL + Search in One

import { XataClient } from './xata';

const xata = new XataClient();

// Full-text search (no Elasticsearch setup needed)
const results = await xata.db.posts.search('react server components', {
  target: ['title', 'content'],
  fuzziness: 1,
  highlight: { enabled: true },
});
Enter fullscreen mode Exit fullscreen mode

2. AI / Vector Search

// Ask questions about your data
const answer = await xata.db.docs.ask('How do I configure authentication?', {
  searchType: 'vector',
  vectorSearch: {
    column: 'embedding',
    contentColumn: 'content',
  },
});
// Returns AI-generated answer based on your data
Enter fullscreen mode Exit fullscreen mode

3. Type-Safe Client (Auto-Generated)

xata codegen
Enter fullscreen mode Exit fullscreen mode
// Auto-generated from your schema
const user = await xata.db.users.create({
  name: 'Alice',        // string - typed
  email: 'a@b.com',     // string - typed
  age: 30,              // number - typed
  avatar: fileBuffer,    // file attachment - typed
});

// Filtering with type safety
const activeUsers = await xata.db.users
  .filter({ age: { $gt: 18 }, 'settings.notifications': true })
  .sort('name', 'asc')
  .getPaginated({ pagination: { size: 20 } });
Enter fullscreen mode Exit fullscreen mode

4. File Attachments

// Upload file directly to a record
await xata.db.products.update('rec_123', {
  image: {
    base64Content: imageBase64,
    mediaType: 'image/png',
    name: 'product.png',
  },
});

// Get file URL with transformations
const url = product.image?.url;
const thumbnail = `${url}?tr=w-200,h-200`;
Enter fullscreen mode Exit fullscreen mode

5. Aggregations

const stats = await xata.db.orders.aggregate({
  totalRevenue: { sum: { column: 'amount' } },
  avgOrderValue: { average: { column: 'amount' } },
  ordersByMonth: {
    dateHistogram: { column: 'created_at', calendarInterval: 'month' },
  },
  topProducts: {
    topValues: { column: 'product_name', size: 10 },
  },
});
Enter fullscreen mode Exit fullscreen mode

6. Branching (Like Git)

# Create a branch for testing
xata branch create feature-new-schema

# Make schema changes on the branch
xata schema edit --branch feature-new-schema

# Merge when ready
xata branch merge feature-new-schema
Enter fullscreen mode Exit fullscreen mode

Free Tier

Feature Free
Records 750K
Storage 2GB
Search 250K queries/month
AI questions 250/month
File storage 2GB
Branches 15

Xata vs Supabase vs PlanetScale

Xata Supabase PlanetScale
Database PostgreSQL PostgreSQL MySQL
Full-text search Built-in Via pg_trgm No
Vector search Built-in Via pgvector No
File storage Built-in Separate bucket No
Branching Yes No Yes
Type generation Auto Via PostgREST types No
AI queries Built-in Via Edge Functions No

Getting Started

npm install @xata.io/cli -g
xata init
xata codegen
Enter fullscreen mode Exit fullscreen mode

The Bottom Line

Xata is the database that does everything. PostgreSQL for your data, Elasticsearch for your search, vector DB for your AI, and file storage for your uploads — all in one API.


Need data tools? I build scraping solutions. Check my Apify actors or email spinov001@gmail.com.

Top comments (0)