Frequently Asked Questions

Product Features & Capabilities

How can I use Hygraph to build real-time in-app notifications in a React application?

Hygraph can be used to build real-time in-app notifications in React by leveraging its content management capabilities, webhooks, and integration with WebSockets. The process involves configuring Hygraph to send webhook requests when content is published, setting up a backend to receive these webhooks and broadcast notifications to connected clients via WebSockets, and implementing a React frontend that listens for these notifications and displays them to users. The full tutorial and code are available in the public GitHub repository. Note: This approach is best suited for prototyping and learning; production deployments may require additional security and scaling considerations.

What are the prerequisites for implementing in-app notifications with Hygraph and React?

To follow the tutorial for in-app notifications with Hygraph and React, you need: Node.js, a code editor (such as VS Code), a Hygraph account, an ngrok account and download, and optionally Google Chrome for testing WebSocket connections. These tools are required to set up the backend, expose it to the internet, and test real-time notifications. Note: Production environments may require additional infrastructure and security measures.

What field types and schema setup are required in Hygraph for in-app notifications?

The recommended schema for in-app notifications in Hygraph includes an enumeration for notification intent (with values: info, warning, error, success) and a Notification model with fields: Title (single line text), Message (multi line text), and Intent (dropdown linked to the enumeration). This structure allows you to categorize notifications by severity and display them appropriately in your frontend. Note: More complex notification types may require additional fields or models.

How does Hygraph integrate with webhooks and WebSockets for real-time notifications?

Hygraph can be configured to send webhook requests to a specified endpoint when content events (such as publishing a notification) occur. A backend service receives these webhooks and broadcasts the notification data to all connected clients via WebSockets. The frontend (e.g., a React app) listens for these WebSocket messages and renders notifications in real time. Note: This architecture requires a running backend and may need further adaptation for large-scale or production use.

What are some limitations or edge cases when using Hygraph for in-app notifications?

This tutorial demonstrates a basic setup for real-time notifications using Hygraph, webhooks, and WebSockets. Limitations include the need for a locally running backend, manual ngrok tunneling for webhook exposure, and a simple notification schema. For production use, you may need to address authentication, scaling, error handling, and persistent storage. Detailed limitations not publicly documented; ask sales or consult the documentation for specifics on production readiness.

Technical Requirements & Implementation

What APIs does Hygraph provide for integration and automation?

Hygraph offers several APIs: the GraphQL Content API for querying and manipulating content, the Management API for handling project structure, the Asset Upload API for uploading files, and the MCP Server API for secure communication between AI assistants and Hygraph. Each API is documented in detail in the API Reference documentation. Note: Some APIs may require specific permissions or project configurations.

What technical documentation is available for developers using Hygraph?

Hygraph provides extensive technical documentation, including API references, schema guides, integration tutorials, and getting started guides. Key resources include the API Reference, Getting Started guides, and integration docs for platforms like Mux, Akeneo, and Auth0. For AI features, see the AI Agents Documentation. Note: Documentation is updated regularly; check the official site for the latest information.

How long does it take to implement Hygraph for a new project?

Implementation time varies by project complexity. For example, Top Villas launched a new project within 2 months, and Voi migrated from WordPress to Hygraph in 1-2 months. Starter projects and structured onboarding can accelerate adoption. Note: Large-scale or highly customized projects may require additional time for integration and testing.

Security & Compliance

What security and compliance certifications does Hygraph hold?

Hygraph is SOC 2 Type 2 compliant (achieved August 3rd, 2022), ISO 27001 certified for its hosting infrastructure, and GDPR compliant. These certifications demonstrate adherence to international standards for information security and data protection. Note: For industry-specific compliance requirements, consult Hygraph's Secure Features page or contact support.

What security features are available in Hygraph?

Hygraph provides granular permissions, SSO integrations (OIDC/LDAP/SAML), audit logs, encryption in transit and at rest, regular backups with one-click recovery, and secure API policies (custom origin policies and IP firewalls). All endpoints use SSL certificates. Note: Some features may require specific plan levels or configurations.

Performance & Integrations

How does Hygraph perform for high-throughput and low-latency content delivery?

Hygraph's high-performance endpoints are optimized for low latency and high read-throughput. The read-only cache endpoint delivers 3-5x latency improvement, and the platform actively measures GraphQL API performance. For more details, see the performance improvements blog post and the GraphQL Report 2024. Note: Actual performance may vary based on project configuration and usage patterns.

What integrations does Hygraph support?

Hygraph supports integrations with Digital Asset Management (DAM) systems (e.g., Aprimo, AWS S3, Bynder, Cloudinary, Imgix, Mux, Scaleflex Filerobot), hosting and deployment platforms (Netlify, Vercel), Product Information Management (Akeneo), commerce solutions (BigCommerce), and translation/localization tools (EasyTranslate). For a full list, visit the Hygraph Marketplace. Note: Integration availability may depend on your plan and project setup.

Use Cases & Customer Success

Who can benefit from using Hygraph?

Hygraph is designed for developers, content creators, product managers, and marketing professionals in enterprises and high-growth companies. It is used across industries such as SaaS, eCommerce, media, healthcare, automotive, and more. Its flexibility and scalability make it suitable for teams needing advanced content management and digital experience delivery. Note: Teams with highly specialized or legacy requirements should evaluate fit with their technical stack.

What business impact have customers seen with Hygraph?

Customers have reported faster time-to-market (e.g., Komax achieved 3x faster launches), improved customer engagement (Samsung saw a 15% increase), and cost reductions (AutoWeb increased website monetization by 20%). For more examples, see the Hygraph case studies. Note: Results may vary based on implementation and business context.

What feedback have customers given about Hygraph's ease of use?

Customers have praised Hygraph for its intuitive interface, quick adaptability, and accessibility for non-technical users. For example, Sigurður G. (CTO) noted the UI is intuitive, and Charissa K. (Senior CMS Specialist) described it as fast to comprehend and localizable. Multiple reviews highlight the ease of setup and use for diverse teams. Note: Some advanced features may require technical expertise.

What industries are represented in Hygraph's customer case studies?

Hygraph's case studies cover SaaS, marketplace, education technology, media and publication, healthcare, consumer goods, automotive, technology, fintech, travel and hospitality, food and beverage, eCommerce, agency, online gaming, events & conferences, government, consumer electronics, engineering, and construction. See the full list at Hygraph case studies. Note: Some industries may have unique requirements not covered in standard case studies.

Pain Points & Problem Solving

What common pain points does Hygraph address for content teams and developers?

Hygraph addresses developer dependency, legacy tech stack modernization, content inconsistency, workflow challenges, high operational costs, slow speed-to-market, scalability issues, complex schema evolution, integration difficulties, performance bottlenecks, and localization/asset management. These are solved through its GraphQL-native architecture, content federation, user-friendly tools, and enterprise-grade features. Note: Some highly specialized needs may require custom solutions or additional integrations.

LLM optimization

When was this page last updated?

This page wast last updated on 12/12/2025 .

Register now

Creating in-app notifications in React with Hygraph

Learn how to build in-app notifications with Hygraph, webhooks, and WebSockets with a React.js frontend.
Cameron Pavey

Last updated by Cameron 

Jan 21, 2026

Originally written by Cameron

Creating in-app notifications in React with Hygraph

Almost everyone is familiar with notifications these days. They can be divided into two broad groups: push notifications and in-app notifications.

Because push notifications are handled by the user's mobile device or browser, they must be implemented in specific ways. In-app notifications, however, are displayed in your app, so it is entirely up to you to decide how they will be implemented—from the look and feel to the technology behind them.

This customizability of in-app notifications has the benefit of allowing them to be deeply integrated with your application, which leads to a better user experience than generic push notifications. However, because in-app notifications differ on a case-by-case basis, it can be hard to implement them. There is no single "right way" to do it.

What most in-app notifications have in common, however, is that they provide a way for you to send content to users who are actively engaged with your application. This is the best window of opportunity for you to share news such as new features, sales, or promotions with them.

In this tutorial, you will learn how to build simple in-app notifications using Hygraph's powerful content system, webhooks, and WebSockets with a React.js frontend. The in-app notifications will show the user some text fields and a color to indicate the importance of the notification.

#Project overview

Before you jump in, review this sequence diagram to get an understanding of how the different components will interact:

Sequence diagram for React in-app notifications, connecting Hygraph webhooks via Ngrok to WebSockets

Hygraph can be configured to send requests to a webhook endpoint when certain events happen. Because you will be running the backend locally, ngrok allows you to expose the backend through a tunnel to the internet, which Hygraph can use as the webhook endpoint. When the backend receives a request on the webhook endpoint, it will emit the data it received to all connected clients via WebSockets. Lastly, when the frontend receives a WebSocket message containing a notification, the frontend will render it.

The completed code for this tutorial can be found in this public GitHub repo.

#Prerequisites

To follow along with this tutorial, you will need a few things:

  • Node.js
  • A code editor. VS Code is a good choice if you don't have a preference.
  • A Hygraph account
  • An Ngrok account and the corresponding download for your OS of choice
  • Optional: Google Chrome or a Chrome-based browser for running a particular browser extension for testing the WebSocket connection. If you don't have Chrome or don't want to install it, this can be skipped.

#Setting up Hygraph

The first piece of the puzzle is Hygraph. Hygraph is a content platform that offers a lot of flexibility. In this tutorial, you will use it to publish pieces of content and have them automatically sent via webhook to your app's backend.

If you haven't already done so, create an account. Once you are signed in, select the option to create a new blank project from the home screen. Give it a name like Notification demo and then click Add project:

Hygraph dashboard showing the 'New project' modal to create the 'Notification demo' backend

Once the new project is created and you are taken to the project dashboard, from the left-hand menu, select Schema. In the new menu that appears, click on Add next to Enumerations. This will open a dialog that prompts you for some details. The enumeration you are creating will denote the "intent" of your notifications so that you can show notifications with different severities. Fill out the dialog with these details, as shown in the screenshot below:

  • Display name: Use intent.
  • API ID: Use Intent.
  • Description: This is optional; you can leave it blank.
  • Enumeration values: Use info, warning, error, and success, pressing Enter after each value.

Configuring an 'Intent' enumeration in Hygraph with values 'info', 'warning', 'error', and 'success'

Then click Add Enumeration:

Next, at the top of the Schema menu, click the Add button next to Models. This will open a new dialog that lets you create the model representing your notifications. Fill out the dialog with these details, as shown in the screenshot below:

  • Display name: Use Notification.
  • API ID: Use Notification.
  • Plural API ID: Use Notifications.
  • Description: This is optional; you can leave it blank.

Creating a 'Notification' content model in Hygraph using the 'Add Model' modal

Then click Add Model.

Hygraph will take you to a new page, where you will be prompted to add fields to your model. You can select fields from the right-hand menu. For this tutorial, add the following fields:

  • Single line text: Use Title as the field name.
  • Multi line text: Use Message as the field name.
  • Dropdown: Use Intent as the field name. For this one, select your Intent enumeration as the value for the Enumeration field.

With these fields created, your model should look something like this:

Hygraph schema for the 'Notification' model, showing 'Title', 'Message', and 'Intent' fields

Next, you must configure a webhook for this model to ensure everything is working as expected.

Select Webhooks at the bottom of the left-hand menu and then choose Add Webhook. This will open a form that lets you configure your webhook.

Because you have not created the backend yet, you can use a simple webhook testing service to verify that everything is working. In a new tab, go to https://webhook.site/, where you will be given a unique URL. Copy this URL, and use it as the value for Url in the Hygraph webhook form.

Under Triggers, select your model (notification) as well as the stage (Published) and action (Publish) on which you wish it to trigger. Your completed form should look something like this:

Configuring a Hygraph webhook to send notifications via POST request, triggered by publishing 'notification' content

Submit the form by clicking Add in the top-right corner.

Next, in the left-hand menu, select Content and then Add entry. Fill out the three fields—use My title for Title, My message for Message, and success for Intent, as shown below—then click Save & publish.

Hygraph content editor creating a new 'Notification' entry with a 'success' intent ready to publish

Once that is saved, go back to the webhook.site tab. You should see that it has received a message containing the values you specified:

Webhook.site dashboard displaying the JSON payload from a Hygraph webhook 'Notification' event

This verifies that everything on Hygraph is configured correctly.

Once you have created the backend, you will change the webhook URL; for now, you can leave it as is.

#Creating the backend

The next thing you need to create is the backend service that will do two things. First, it will receive POST request webhooks coming from Hygraph. Second, it will host a WebSocket server and emit messages to any connected clients containing the details of the notifications received via the webhook.

This is a simple, contrived form of what would likely be a more complicated application in a real-world scenario, but it serves to demonstrate the architectural patterns in play.

To get started, create a new directory to hold the code for this tutorial. Inside the directory, create another to hold the code for the server:

mkdir -p hygraph-notifications/server
cd hygraph-notifications/server

Once in this directory, you need to install a few dependencies. First, initialize a new npm project (you can accept the default values for any questions it asks), and then install the dependencies as follows:

npm init
npm i -D typescript @types/ws @types/express
npm i body-parser express ws

Next, create a file called tsconfig.json and give it the following content:

{
"compilerOptions": {
"esModuleInterop": true,
"target": "es6",
"module": "commonjs",
"outDir": "./dist/server",
"strict": true,
"sourceMap": true,
"typeRoots": [
"node_modules/@types"
]
},
"exclude": [
"dist",
"node_modules"
]
}

Finally, create a file called index.ts and give it the following content:

import express from "express";
import http from "http";
import WebSocket from "ws";
import bodyParser from "body-parser";
import { randomUUID } from "crypto";
// Create a new express app instance
const app = express();
// Parse JSON bodies
const jsonParser = bodyParser.json();
// Create a new HTTP server
const server = http.createServer(app);
// Create a new WebSocket server
const wss = new WebSocket.Server({ server });
app.post("/webhook", jsonParser, (req, res) => {
// Broadcast the notification to all connected clients
// In a real app, you would probably want to send to specific clients
wss.clients.forEach((client) => {
if (client.readyState === WebSocket.OPEN) {
client.send(
JSON.stringify({
id: randomUUID(), // Generate a random ID for the message
type: "notification", // Give the message a type
// Encode the data from the webhook into the message
data: {
title: req.body.data.title,
message: req.body.data.message,
intent: req.body.data.intent,
},
})
);
}
});
res.sendStatus(200);
});
// Handle new WebSocket connections
wss.on("connection", (ws: WebSocket) => {
// Acknowledge connection
ws.send(JSON.stringify({ id: randomUUID(), type: "connection", data: null }));
});
const port = process.env.PORT || 8999;
// Start the server
server.listen(port, () => {
console.log(`Server started on port ${port}`);
});

Comments in this code describe what each section does, but the gist is that it creates a web server to handle the incoming webhook and the WebSocket connections, as detailed above.

Because the code is written in TypeScript, you need to transpile it before it can be executed. To do this, run the following commands:

./node_modules/.bin/tsc
node dist/server/index.js

You should see the output in your terminal saying Server started on port 8999.

At this stage, testing everything is working so far is a good idea. The easiest way to do this before you've created the frontend is to use the Simple WebSocket Client Google Chrome extension.

Install this extension, and then click on the icon it adds near your omnibar. This should take you to a simple UI with a field labeled URL:. In this field, enter ws://localhost:8999 and click Open. You should see something like this:

WebSocket test

This output indicates that the client has successfully connected to your WebSocket server.

#Setting up ngrok

Next, you will use ngrok to expose your server to the internet so that Hygraph can send webhook requests to it.

If you haven't already done so, create an account with ngrok, follow the instructions to download the ngrok binary for your OS of choice and authenticate it with your ngrok account.

Once this is done, running the following command will start an ngrok session on your machine:

ngrok http 8999

You should see some output like this:

ngrok running in terminal

Copy the URL from the Forwarding line (blurred above), and go back to Hygraph. Navigate back to the Webhooks menu item at the bottom of the left-hand menu, and edit your existing webhook. Replace the previous URL with the ngrok URL you copied, suffixed with /webhook, as this is the route your server is configured to listen on. Save the changes to the webhook configuration by clicking Update in the top-right corner.

Next, navigate back to the Content menu. Click Add Entry and create another notification by filling out and submitting the form.

If you look in your ngrok terminal, you should see that it logged a POST request to the /webhook endpoint. If so, look in your WebSocket client, where you should see the notification too:

Message received in WebSocket client

If you don't see the message come through, check that the following are all true:

  • The server is running locally.
  • ngrok is running.
  • The URL ngrok gave you is the URL configured in Hygraph and that you suffixed it with /webhook.

To renew the connection, click Close and then Open again in the WebSocket client.

If this works, you are ready to move on to the final piece, the frontend.

#Creating the frontend

You now have data coming from Hygraph via your webhook and being sent to your WebSocket client. If you implement handling for these WebSocket messages in a React application, you can show in-app notifications driven by Hygraph's content system. You will build this React application using TypeScript, Vite, and Tailwind.

To get started, navigate back to your project root directory, and create a new Vite project with the following command:

# From hygraph-notifications/
npm create vite@latest frontend --template react-ts
# If you are using the most recent versions of npm, use the following command instead:
# npm create vite@latest frontend -- --template react-ts
cd frontend
npm install

Next, you need to install some other dependencies for Tailwind and to work with WebSockets:

npm i react-use-websocket
npm i -D tailwindcss postcss autoprefixer
npx tailwindcss init -p

This command would have created a new file called tailwind.config.js. Open this file, and replace its content with the following to ensure that Tailwind watches the appropriate files:

/** @type {import('tailwindcss').Config} */
export default {
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
theme: {
extend: {},
},
plugins: [],
};

Next, you must add Tailwind to your base CSS file and a few reset rules. Open src/index.css, and replace its content with the following:

@tailwind base;
@tailwind components;
@tailwind utilities;
html, body {
padding: 0;
margin: 0;
}
#root {
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}

Finally, open src/App.tsx and replace its content with the following:

import { useCallback, useEffect, useState } from "react";
import useWebSocket from "react-use-websocket";
// Define some types for better autocomplete
type Intent = "success" | "warning" | "error" | "info";
type MessageType = "notification" | "connection";
type MessageData = {
notification: {
title: string;
message: string;
intent: Intent;
};
connection: null;
};
type Message<T extends MessageType> = {
id: string;
type: T;
data: MessageData[T];
};
// Define a map of intents to Tailwind CSS classes to color your notifications
const intentMap: Record<Intent, string> = {
success: "bg-green-500",
warning: "bg-yellow-500",
error: "bg-red-500",
info: "bg-blue-500",
};
function App() {
// Store the message history in state
const [messageHistory, setMessageHistory] = useState<Message<MessageType>[]>(
[]
);
// Connect to the websocket server
const [socketUrl] = useState("ws://localhost:8999");
const { lastMessage } = useWebSocket(socketUrl);
// When a new message is received, parse it and add it to the message history
useEffect(() => {
if (lastMessage !== null) {
const parsedData = JSON.parse(lastMessage.data);
setMessageHistory((prev) => prev.concat(parsedData));
}
}, [lastMessage, setMessageHistory]);
// Define a function to dismiss a notification
const handleDismiss = useCallback(
(message: Message<"notification">) => {
setMessageHistory((prev) => prev.filter((m) => m.id !== message.id));
},
[setMessageHistory]
);
// Filter the message history to only include notifications
const notifications = messageHistory.filter(
(data): data is Message<"notification"> => data.type === "notification"
);
// Render the notifications
if (notifications.length > 0) {
return (
<div className="bg-gray-800 text-white flex justify-center items-center h-full w-full flex-col p-12">
<h1 className="text-3xl font-bold font-sans mb-4">Notifications</h1>
<ul className="w-full">
{notifications.map((message, idx) => (
<li
key={message.id}
className={`w-full p-2 rounded-md my-2 flex items-start justify-start flex-col ${
intentMap[message.data.intent]
}`}
>
<div className="font-bold flex justify-between w-full">
<span>{message.data?.title}</span>
<button onClick={() => handleDismiss(message)}>x</button>
</div>
<div>{message.data?.message}</div>
</li>
))}
</ul>
</div>
);
}
// If there are no notifications, render a waiting message
return (
<div className="bg-gray-800 text-white flex justify-center items-center h-full w-full">
<div>Waiting for notifications...</div>
</div>
);
}
export default App;

The code above has comments describing what each piece does, but essentially, it connects to the WebSocket server running on port 8999 and waits until it receives a message with a type of ”notification”.

Once one of these notifications has been received, it renders the notification with simple styles. The notification's color is based on the intent that you selected in Hygraph when creating the entry, and the rendered notification has a button for dismissing it.

Aside from this, the code includes some types to help with autocomplete. This would likely be spread across multiple files in a real application, but in this contrived example, it is all kept in one file for brevity.

From your terminal, run the following command to start your frontend app:

npm run dev

The output should indicate which port it is running on. Go to this address in your browser, where you should see something like this:

Waiting for notifications

If you have previously stopped the backend service or ngrok, ensure that they are running and that the URL ngrok gives you is still configured for your webhooks in Hygraph. If all these pieces are running, publish a notification from Hygraph. You should see it appear as an in-app notification:

Publishing content to an in-app notification

With that, you can push in-app notifications to your React frontend in real-time using Hygraph's powerful content tools.

#Wrapping up

In this tutorial, you've seen how to use Hygraph, webhooks, WebSockets, and React to implement basic real-time in-app notifications.

This example has kept things simple with just a few text fields and an enumeration. However, Hygraph supports many useful field types, including geo-coordinates, file uploads, and rich text inputs. With this flexibility and the tools and techniques you've seen in this tutorial, there's no limit to the real-time, content-driven experiences you could bring to your application.

If you need to bring content-driven experiences to your application, consider Hygraph, a GraphQL-friendly headless content management system that's easy to work with and simple to integrate with the backend and frontend technologies of your choice.

Blog Author

Cameron Pavey

Cameron Pavey

Technical writer

Cameron is a full-stack dev living and working in Melbourne. He's committed himself to the never-ending journey of understanding the intricacies of quality code, developer productivity, and job satisfaction.

Share with others

Sign up for our newsletter!

Be the first to know about releases and industry news and insights.