Setup

Connect this project to your Xata account, initialize pgroll and run migrations

xataio Updated
Claude Code creating a Xata branch

File contents

Setup Xata project

Connect this project to your Xata account and database.

Steps

  1. Authenticate with Xata (if not already logged in):

    xata auth login
    
  2. Initialize the project:

    xata init
    

    Follow the prompts to select your organization, project and branch.

  3. Get the connection string:

    xata branch url
    
  4. Create .env.local with the connection string:

    echo "DATABASE_URL=<paste connection string>" > .env.local
    
  5. Initialize pgroll (one-time setup):

    xata roll init
    
  6. Run all migrations:

    xata roll start migrations/001_create_users.yaml
    xata roll complete
    xata roll start migrations/002_add_role.yaml
    xata roll complete
    xata roll start migrations/003_add_teams.yaml
    xata roll complete
    
  7. Verify the setup:

    psql $(xata branch url) -c "SELECT * FROM users;"
    

Notes

  • The xata init command creates a .xata folder with configuration
  • Connection strings include credentials — never commit .env.local
  • xata roll init only needs to run once per database

xataio/nextjs-claude-code-starter commit 85e354216e

Frequently asked questions

npx get-skill add xataio/setup