DEV Community

Alex Spinov
Alex Spinov

Posted on

Nhost Has a Free API: The Open-Source Firebase Alternative With GraphQL and Postgres Built In

Firebase gives you speed but takes your data flexibility. Supabase gives you Postgres but requires manual GraphQL setup. Nhost combines both: a managed Postgres database with automatic GraphQL via Hasura, plus auth, storage, and serverless functions.

What Is Nhost?

Nhost is an open-source backend-as-a-service built on Postgres, Hasura, and S3. You get a relational database with automatic GraphQL API generation, authentication, file storage, and serverless functions — all managed and integrated.

The Free API

Nhost offers a free tier:

  • Free plan: 1GB database, 1GB storage, 5GB bandwidth
  • GraphQL API: Auto-generated from your Postgres schema
  • Authentication: Email, social login, magic links, phone
  • File storage: S3-compatible with transformations
  • Serverless functions: Node.js/TypeScript functions
  • Hasura console: Visual data management
  • Real-time subscriptions: GraphQL subscriptions built in

Quick Start

Install the Nhost CLI:

npm install -g nhost
nhost init my-app
cd my-app
nhost up  # Start local development
Enter fullscreen mode Exit fullscreen mode

Define your database schema:

-- migrations/default/1_create_tables/up.sql
CREATE TABLE todos (
  id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
  title text NOT NULL,
  completed boolean DEFAULT false,
  user_id uuid REFERENCES auth.users(id),
  created_at timestamptz DEFAULT now()
);
Enter fullscreen mode Exit fullscreen mode

Query with GraphQL (auto-generated):

# All these queries are auto-generated from your schema
query GetTodos {
  todos(order_by: { created_at: desc }) {
    id
    title
    completed
    created_at
    user {
      displayName
      email
    }
  }
}

mutation AddTodo($title: String!) {
  insert_todos_one(object: { title: $title }) {
    id
    title
  }
}

subscription WatchTodos {
  todos(order_by: { created_at: desc }) {
    id
    title
    completed
  }
}
Enter fullscreen mode Exit fullscreen mode

React integration:

import { NhostClient, NhostProvider } from '@nhost/react';
import { NhostApolloProvider } from '@nhost/react-apollo';

const nhost = new NhostClient({
  subdomain: 'your-subdomain',
  region: 'eu-central-1',
});

function App() {
  return (
    <NhostProvider nhost={nhost}>
      <NhostApolloProvider nhost={nhost}>
        <TodoList />
      </NhostApolloProvider>
    </NhostProvider>
  );
}

function TodoList() {
  const { data, loading } = useQuery(GET_TODOS);
  const { signIn, signOut, user } = useSignInEmailPassword();

  if (!user) return <LoginForm onSubmit={signIn} />;
  return <ul>{data?.todos.map(t => <li key={t.id}>{t.title}</li>)}</ul>;
}
Enter fullscreen mode Exit fullscreen mode

File storage:

// Upload a file
const { error } = await nhost.storage.upload({
  file: selectedFile,
  bucketId: 'default',
});

// Get file URL with transformation
const url = nhost.storage.getPublicUrl({
  fileId: 'file-id',
  width: 300,
  height: 300,
  quality: 80,
});
Enter fullscreen mode Exit fullscreen mode

Why Teams Choose Nhost

A team building a collaborative document editor evaluated Firebase, Supabase, and Nhost. They needed relational data (documents, permissions, comments), real-time sync, and file storage for attachments. Firebase's document model was too limiting. Supabase required manually setting up real-time. Nhost gave them Postgres relations, GraphQL subscriptions, and file storage — all integrated and working together from day one.

Who Is This For?

  • Full-stack developers wanting a complete backend without managing infrastructure
  • GraphQL enthusiasts who want auto-generated APIs from their schema
  • Teams building real-time collaborative applications
  • Startups needing to ship fast with a production-grade backend

Start Building

Nhost gives you the developer experience of Firebase with the power of Postgres and GraphQL. Open source, managed, and free to start.

Need help with backend architecture or GraphQL APIs? I build custom backend solutions — reach out to discuss your project.


Found this useful? I publish daily deep-dives into developer tools and APIs. Follow for more.

Top comments (0)