Skip to content
Aurabase Logo
aurabase

Migrate from Nhost

Both Nhost and Aurabase run on standard PostgreSQL. Your SQL schema, rows, and bcrypt password hashes transfer directly; Hasura GraphQL metadata permissions are translated once into native PostgreSQL Row-Level Security policies — and opt-in pg_graphql lets you migrate GraphQL clients incrementally.

How-to guide11 min readLevel intermediate

Quick answer#

To migrate from Nhost to Aurabase, dump your Nhost public schema with pg_dump, restore it into your dedicated Aurabase PostgreSQL 18 database using aura db restore, batch-import auth.users via POST /v1/auth/admin/users/import or aura.authAdmin.importUsers() (keeping existing bcrypt password hashes with zero password resets), and translate Hasura role metadata into native PostgreSQL RLS policies. If your frontend still uses GraphQL, enable Aurabase's built-in pg_graphql extension while migrating progressively to PostgREST REST or keeping GraphQL permanently.

Architecture mapping#

Nhost componentAurabase equivalentWhat carries over vs. what changes
PostgreSQL databaseDedicated PostgreSQL 18 (CloudNativePG)Tables, constraints, indexes, SQL functions, triggers transfer via pg_dump
Hasura GraphQL EnginePostgREST REST API + opt-in pg_graphqlREST is native by default; enable pg_graphql per project if keeping GraphQL
Hasura YAML permissionsNative PostgreSQL RLS (auth.uid(), JWT claims)Rewritten once as SQL CREATE POLICY (single security layer inside Postgres)
Hasura Auth (auth.users)Aurabase Auth (OAuth 2.1, Passkeys, TOTP MFA)bcrypt hashes carry over via bulk import (auto-upgraded to Argon2id on login)
Hasura Storage (storage.files)Sovereign S3 Storage (SeaweedFS)Files copy cleanly; bucket policies become per-path RLS
Serverless FunctionsEdge Functions (Deno/TypeScript or WASM)Node/TS handlers port cleanly to Deno.serve()

1. Export and restore PostgreSQL#

Export only the application schema (public) — do not dump Nhost's internal hdb_catalog, auth, or storage schemas:

# 1. Dump Nhost public schema (plain SQL, no ownership or ACLs)
pg_dump "$NHOST_DATABASE_URL" \
  --schema=public \
  --no-owner \
  --no-acl \
  --format=plain \
  --file=nhost-public.sql

# 2. Link your Aurabase project and inspect the restore plan first
aura link <project>
aura db restore ./nhost-public.sql --dry-run

# 3. Replay into Aurabase PostgreSQL 18
aura db restore ./nhost-public.sql --continue-on-error
Foreign keys referencing auth.users(id)

Nhost apps often declare REFERENCES auth.users(id) on tables like profiles or projects. Because Aurabase Auth manages users outside the project's auth.users table, those foreign key statements fail during restore. Running --continue-on-error restores the table and keeps the user_id UUID values intact; your imported users retain matching IDs so RLS rules like user_id = auth.uid() work unchanged.

2. Import Nhost users without resetting passwords#

Nhost (hasura-auth) stores passwords as standard $2a$/$2b$ bcrypt hashes — directly supported by Aurabase's bulk import API (up to 1,000 users per request, transparently re-hashed to Argon2id on next login).

First export auth.users from Nhost as JSON:

psql "$NHOST_DATABASE_URL" -Atc "
SELECT json_agg(row_to_json(u))
FROM (
  SELECT
    email,
    email_verified,
    password_hash,
    display_name AS name,
    metadata AS user_metadata
  FROM auth.users
  WHERE disabled = false AND email IS NOT NULL
) u;
" > nhost-users.json

Then batch-import into Aurabase with @aurabase/aurabase-js (1,000 users per batch):

import { readFileSync } from 'node:fs'
import { createClient } from '@aurabase/aurabase-js'

const aura = createClient(
  process.env.NEXT_PUBLIC_AURABASE_URL!,
  process.env.AURABASE_SERVICE_ROLE_KEY!,
)

type NhostUser = {
  email: string
  email_verified: boolean
  password_hash?: string | null
  name?: string | null
  user_metadata?: Record<string, unknown> | null
}

const raw: NhostUser[] = JSON.parse(readFileSync('./nhost-users.json', 'utf8'))

for (let i = 0; i < raw.length; i += 1000) {
  const batch = raw.slice(i, i + 1000).map((u) => ({
    email: u.email,
    emailVerified: Boolean(u.email_verified),
    ...(u.password_hash ? { passwordHash: u.password_hash } : {}),
    ...(u.name ? { name: u.name } : {}),
    ...(u.user_metadata ? { userMetadata: u.user_metadata } : {}),
  }))

  const { data, error } = await aura.authAdmin.importUsers(batch)
  if (error) throw new Error(`Batch ${i} failed: ${error.message}`)
  console.log(`Batch ${i}: created=${data.created} skipped=${data.skipped} errors=${data.errors}`)
}
Delete nhost-users.json after import

The exported JSON contains live password hashes. Delete it from disk and shell history immediately once the import summary shows errors=0.

3. Convert Hasura permissions to native Postgres RLS#

Hasura stores row permissions in external YAML metadata using X-Hasura-User-Id and X-Hasura-Role. On Aurabase, every access rule lives inside PostgreSQL itself — meaning REST, GraphQL (pg_graphql), Realtime CDC, and MCP all obey the exact same policy:

Hasura YAML permissionEquivalent Aurabase PostgreSQL RLS
filter: { user_id: { _eq: X-Hasura-User-Id } }USING (user_id = auth.uid())
check: { user_id: { _eq: X-Hasura-User-Id } }WITH CHECK (user_id = auth.uid())
role: userTO aura_authenticated
role: publicTO aura_anon
columns: [id, title, status]Column-level GRANT SELECT (id, title, status) or SQL view
ALTER TABLE tasks ENABLE ROW LEVEL SECURITY;

CREATE POLICY tasks_owner_select ON tasks
  FOR SELECT TO aura_authenticated
  USING (user_id = auth.uid());

CREATE POLICY tasks_owner_insert ON tasks
  FOR INSERT TO aura_authenticated
  WITH CHECK (user_id = auth.uid());

CREATE POLICY tasks_owner_update ON tasks
  FOR UPDATE TO aura_authenticated
  USING (user_id = auth.uid())
  WITH CHECK (user_id = auth.uid());

4. GraphQL (pg_graphql) or PostgREST SDK#

You have two paths for your frontend queries:

  • Keep GraphQL: enable pg_graphql in your Aurabase project (opt-in, inherits your Postgres RLS automatically) and point your GraphQL client to /graphql (see GraphQL docs).
  • Switch to typed REST (recommended for simplest stack): replace Apollo/urql GraphQL queries with @aurabase/aurabase-js:
// BEFORE (Nhost + GraphQL)
// const { data } = await nhost.graphql.request(`query { tasks { id title } }`)

// AFTER (Aurabase typed SDK — no GraphQL layer to maintain)
import { createClient } from '@aurabase/aurabase-js'

const aura = createClient(
  process.env.NEXT_PUBLIC_AURABASE_URL!,
  process.env.NEXT_PUBLIC_AURABASE_ANON_KEY!,
)

const { data: tasks, error } = await aura.from('tasks').select('id, title')

5. Migrate Storage files and Serverless Functions#

  1. Storage: list files from Nhost's storage.files table (preserving bucket_id and name), download them via Nhost Storage, and upload them to matching Aurabase S3 buckets with aura.storage.from(bucket).upload(path, file).
  2. Functions: convert Express/Node handlers in Nhost's functions/ directory to standard Web Request/Response handlers (Deno.serve(async (req) => ...)) and deploy with aura functions deploy.

Known caveats & cutover checklist#

  • Hasura Event Triggers: replace Hasura HTTP event triggers with PostgreSQL triggers + Aurabase Webhooks or Realtime CDC.
  • Hasura Actions / Remote Schemas: move custom GraphQL resolvers into Aurabase Edge Functions or PostgreSQL rpc() functions.
  • Cutover order: freeze writes on Nhost → run final pg_dump + aura db restore → import delta users → test RLS with simulate-policy → swap DNS/environment variables.

To go further#

@aurabase/aurabase-js@0.7.5 · aura@0.3.4↗ Report a problem