DEV Community

Cover image for Hasura vs Supabase: a quick comparison
Denis González
Denis González

Posted on

Hasura vs Supabase: a quick comparison

When you are in a hurry to build a backend sometimes you just need an API to insert and retrieve data from a database. I have found that Hasura and Supabase both accomplish this goal. And here we explain what are the features of each one and you can see by your self which suits better for your project.

Hasura:

Hasura is an open-source engine that provides instant GraphQL APIs on top of existing databases. It allows developers to quickly build and deploy scalable and real-time applications by auto-generating a GraphQL API based on the database schema.

The main features of Hasura include:

  1. Instant GraphQL API: Hasura automatically generates a GraphQL API for your database, including queries, mutations, subscriptions, and real-time updates. This eliminates the need to write boilerplate code for CRUD operations.
  2. Real-time capabilities: Hasura provides real-time functionality out of the box. It supports GraphQL subscriptions, which allow you to subscribe to changes in your data and receive real-time updates. This makes it ideal for building applications that require live data updates, such as chat applications, dashboards, and collaborative tools.
  3. Authorization and authentication: Hasura provides a flexible and powerful authorization system that integrates with your existing authentication methods. You can define fine-grained access controls at the field and row level using declarative GraphQL permissions. This ensures that only authorized users can access and modify the data.
  4. Remote schemas and custom business logic: Hasura allows you to integrate external services and APIs into your GraphQL API. You can define remote schemas that fetch data from other APIs and combine them with your database schema. Additionally, you can write custom business logic using webhooks, event triggers, and serverless functions.
  5. Performance and scalability: Hasura is designed to be highly performant and scalable. It uses a combination of caching, intelligent query execution, and subscription handling to optimize the performance of your GraphQL API. It can handle high loads and automatically scales horizontally as your application grows.

Hasura provides client libraries in various programming languages to simplify the integration of the generated GraphQL API into your application. The client libraries include:

  1. JavaScript: Hasura provides a JavaScript client library called @apollo/client which is widely used in the JavaScript ecosystem. It allows you to interact with the Hasura GraphQL API from your JavaScript or TypeScript application.
  2. React: Hasura has good support for React through the react-apollo library. It provides React components and hooks that make it easy to fetch and mutate data from the Hasura GraphQL API in your React applications.
  3. iOS and Swift: Hasura provides a Swift client library called Apollo iOS. It enables iOS developers to consume the Hasura GraphQL API and interact with it using strongly-typed queries and mutations.
  4. Android and Kotlin: Hasura offers a Kotlin-based client library called Apollo Android. It allows Android developers to integrate with the Hasura GraphQL API in their Kotlin or Java applications, providing type-safe queries and mutations.

These are some of the widely-used client libraries directly supported by Hasura, but since Hasura generates a standard GraphQL API, you can use any GraphQL client library in your preferred programming language to interact with the Hasura GraphQL API.

Supabase

Supabase is an open-source backend-as-a-service (BaaS) platform that aims to simplify the development of web and mobile applications. It provides developers with a suite of tools and services to build scalable and secure applications rapidly. Supabase combines the power of a PostgreSQL database with a real-time WebSocket-based API and authentication system.

Main Features

  1. Real-time and RESTful API: Supabase offers both real-time and RESTful APIs to interact with your data. The real-time API is built on top of PostgreSQL's logical decoding feature, allowing you to receive instant updates in real-time. The RESTful API provides a traditional HTTP-based approach for interacting with your data.
  2. PostgreSQL Database: Supabase utilizes PostgreSQL, a powerful and reliable open-source relational database management system (RDBMS). It provides ACID-compliant transactions, powerful querying capabilities, and support for advanced data types.
  3. Authentication and Authorization: Supabase provides an authentication system out of the box, allowing you to handle user sign-up, sign-in, and password reset flows easily. It supports various authentication methods, including email/password, social logins (OAuth), and token-based authentication. Fine-grained access control and role-based permissions can be defined to secure your data.
  4. Real-time Subscriptions: With Supabase, you can subscribe to changes happening in your database tables and receive real-time updates using the WebSocket-based subscription API. This feature is ideal for building collaborative applications, chat systems, and live data-driven experiences.
  5. Storage: Supabase offers an object storage feature that allows you to store and serve files in your applications. It provides APIs to upload, download, and manage files, making it easy to handle user-generated content such as images, videos, and documents.
  6. Supabase UI: Supabase provides a set of pre-built UI components called Supabase UI, designed to streamline the development process. These components are customizable and help you create a consistent and user-friendly interface for your applications.

Client Libraries

Supabase provides client libraries in various programming languages to simplify integration with their services. The supported client libraries include:

  1. JavaScript: Supabase offers a JavaScript client library called @supabase/supabase-js. It provides an intuitive API to interact with the Supabase services from your JavaScript or TypeScript applications.
  2. React: Supabase has a React-specific library called react-supabase. It provides React hooks and components that make it easy to work with Supabase in your React applications.
  3. Android and Kotlin: Supabase offers an Android client library called supabase-android. It enables Android developers to integrate Supabase services into their Kotlin or Java applications, providing a convenient API for data access and authentication.
  4. iOS and Swift: Supabase provides an iOS client library called supabase-swift. It allows iOS developers to interact with Supabase services in their Swift applications, offering features such as data querying, real-time subscriptions, and authentication.
  5. Supabase also provides RESTful API documentation, which allows developers to interact with the Supabase services using any programming language that supports HTTP requests.

Comparison:

Hasura Supabase
Backend Type GraphQL engine Backend-as-a-Service (BaaS)
Features - Instant GraphQL API - Real-time and RESTful API
- Real-time capabilities - PostgreSQL database
- Authorization and authentication - Authentication and authorization
- Remote schemas and custom business logic - Real-time subscriptions
- Performance and scalability - Storage for files
- Supabase UI components
Client Libraries JavaScript, React, iOS (Swift), Android (Kotlin) JavaScript, React, iOS (Swift), Android (Kotlin)
Primary Use Case Building real-time applications, data-driven apps Rapid development of web and mobile apps
Data Source Any existing database PostgreSQL database
Open-source Yes Yes
Community Support Active community and documentation Active community and documentation
Hosting Options Self-hosted, cloud, or managed services Self-hosted, cloud, or managed services

Top comments (3)

Collapse
 
leob profile image
leob

You forgot to compare one thing: pricing !

I quickly looked up Hasura's pricing page, and apart from their free tier, their first tier seems rather prohibitively expensive - "$1.50 per hour", that's over $1000 per month ! ... while Supabase charges $25 per month for their first non-free basic plan ... get the lowdown here:

reddit.com/r/Hasura/comments/10t26...

$1000 per month might be okay if you're a big enterprise, or an already very successful startup, but for the rest of us, no, thank you (apart from the fact that Supabase's offer, for those $25, seems more comprehensive - and their documentation is just excellent).

Collapse
 
degomon profile image
Denis González

Both can be selfhosted with postgresql.

Collapse
 
leob profile image
leob

Yeah okay but then you're again responsible for hosting, scaling, monitoring ... Supabase gives you a great package for $25, Hasura pricing is ridiculous.