---
title: "Neon - Xata"
description: "Learn how to migrate your Neon PostgreSQL database to Xata using xata clone"
source: "https://xata.io/docs/migrations/neon"
---

Skip to main content

## ​Prerequisites

- Access to Neon Console
- Xata account and project setup with a running `main` branch

## ​Install and configure the Xata CLI

Install the Xata CLI:

```
curl -fsSL https://xata.io/install.sh | bash
```

Authenticate with your Xata account:

```
xata auth login
```

## ​Find the Neon connection string

Neon connection strings typically look something like this:

```
postgresql://neondb_owner:your_password@hostname.c-3.us-east-1.aws.neon.tech/dbname?sslmode=require&channel_binding=require
```

To find yours, follow these steps:

1. Go to Neon Console → Your Project
2. Select the branch you want to copy from
3. Click “Connect” to get the “Connect to your database” modal
4. Unset the Connection pooling toggle
5. Select “Connection string” in the dropdown
6. Click “Copy snippet” to copy it, including the password

## ​Initialize Xata project

Go to a local folder that you want to save the Xata configuration to and initialize it like this:

```
xata init
```

Select your organization and project you want to use. For the database name you can either choose a new one (e.g `xata`) or use the same that you have in Neon. If the database doesn’t exist, it will be created. In case you need to redo this step, you can reset the configuration by deleting the `.xata/project.json` file and running `xata init` again.

## ​Start the migration

Begin the data transfer:

```
xata clone start --validation-mode relaxed --source-url '<<neon-connection-string>>'
```

Depending on how large the source database is, this step might take a while. A progress bar will show you the progress in the CLI.

## ​Verification

After migration, verify your data:

1. **Connect to Xata Branch**:

   ```
   psql `xata branch url`
   ```

2. **Check Data Integrity**:

   ```
   -- List tables
   \dt

   -- Compare row counts
   SELECT COUNT(*) FROM your_table;

   -- Check sample data
   SELECT * FROM your_table LIMIT 10;
   ```

## ​Update your application

If you’re using the `@neondatabase/serverless` driver, you can continue using it with Xata—just update your connection string. Xata implements the same serverless protocol.

1. Get your Xata connection string:

   ```
   xata branch url
   ```

2. Update your environment variable:

   ```
   DATABASE_URL=<your-xata-connection-string>
   ```

Your existing code works without changes:

```
import { neon } from '@neondatabase/serverless';

const sql = neon(process.env.DATABASE_URL);
const users = await sql`SELECT * FROM users`;
```

Tip

For more details on using the serverless driver with Xata, see the [Serverless Proxy](/docs/core-concepts/serverless-proxy) documentation.

Was this page helpful?

[Previous](/docs/migrations/gcp-cloudsql)

[Supabase](/docs/migrations/supabase)

[Next](/docs/migrations/supabase)
