Deploy Xata PostgreSQL + Node.js + Drizzle

Deploy and Host Xata PostgreSQL + Node.js + Drizzle with Railway

Deploy Xata PostgreSQL + Node.js + Drizzle

railway-nodejs-drizzle-xata

xataio/railway-nodejs-drizzle-xata

Just deployed

Deploy and Host Xata PostgreSQL + Node.js + Drizzle on Railway

Xata is a fully-managed PostgreSQL service offering advanced features like:

  • Copy-on-Write branching
  • Point-in-Time (PITR) recovery
  • Separation of storage from compute
  • High availability, redundancy, and scalability
  • Long list of PostgreSQL extensions, including pgvector, postgis, pg_cron, etc.
  • Built-in query editor, AI self-optimizations, advanced observability
  • Expert support in PostgreSQL

About Hosting Xata PostgreSQL with Railway

This template contains a sample Node.js application configured to use Drizzle ORM to connect to the Xata PostgreSQL service. You can use this template, or simply follow the same pattern in your own application.

This template is for Node.js, but Xata PostgreSQL can be used with any programming language or framework that supports PostgreSQL.

The DATABASE_URL is the only environment variable required. Set it to the PostgreSQL connection string, which you can copy from the branch overview page in the Xata console.

Common Use Cases

  • A fully-managed PostgreSQL database to store all your data: users, organizations, workspaces, etc.
  • Implement infinite chat history and memory for your AI agent. Works with any AI framework that uses PostgreSQL.
  • Use the pgvector extension to create similarity search, product recommendations, or AI RAG use cases.

Dependencies for Xata + Node.js + Drizzle Hosting

  • Xata account: You can create one by logging in at console.xata.io . Once you login, create an organization, and a project inside the organization. Start a main branch for your database. From the branch overview page, copy the connection string set the DATABASE_URL to it.

Deployment Dependencies

  • Drizzle, which is already included in the template.

Implementation Details

This is the minimal code to instantiate Drizzle and use together with Xata:

const { drizzle } = require("drizzle-orm/postgres-js");
const postgres = require("postgres");

// Database connection configuration
const client = postgres(process.env.DATABASE_URL);
const db = drizzle(client);

module.exports = { db, client };

Then in a route you can execute SQL like this:

const { db } = require("../config/database");
const result = await db.execute("SELECT version()");

Set the DATABASE_URL in your Railway project settings, and you are good to go.

Why Deploy Xata PostgreSQL with Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By using Xata PostgreSQL together with Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


Template Content

railway-nodejs-drizzle-xata

xataio/railway-nodejs-drizzle-xata

More templates in this category

View Template
ReadySet
A lightweight caching engine for Postgres

View Template
Simple S3
Deploy a S3-compatible storage service with a pre-named bucket.

View Template
Flare
A modern, lightning-fast file sharing platform built for self-hosting