Here's a quick summary of everything we released in Q1 2024.

Headless CMS for Node.js

Hygraph is the ideal Headless CMS for Node.js websites and applications. Read further to learn how our API-first CMS allows you to add components to your Node.js apps in minutes and enable your website's content to be managed from a powerful CMS.

Step #1 - Construct your query and fetch the data from Hygraph

To query a GraphQL API in Node.js, you'll typically use a package like graphql-request or axios. On the right is a simple example using graphql-request.

The gql template literal tag is used to define your query, which is a string that represents a GraphQL query. This script will send a request to the GraphQL server and log the response data to the console. If there are any errors, it will log those to the console as well.

const { request, gql } = require('graphql-request');
const endpoint = 'https://api-<region>.hygraph.com/v2/<some hash>/master';
const graphQLQuery = gql`
{
products {
name
description
slug
availability
image
}
}
`;
request(endpoint, graphQLQuery)
.then((data) => console.log(data))
.catch((error) => console.error(error));

Step #2 - Use GraphQL mutations to store data to headless CMS

Aside from just querying content, with Hygraph's GraphQL API you can also store, edit and delete the content. The variables object contains the data for the new product that you want to create.

This script sends a mutation request to the GraphQL server to create a new product with the provided details, and logs the response. If there's an error, it will be logged to the console as well. Always ensure that the variables you pass match the expected input types in your GraphQL schema.

const { request, gql } = require('graphql-request');
const endpoint = 'https://api-<region>.hygraph.com/v2/<some hash>/master';
const graphQLMutation = gql`
mutation AddProduct($name: String!, $description: String!, $slug: String!, $availability: Boolean!, $image: String!) {
createProduct(data: { name: $name, description: $description, slug: $slug, availability: $availability, image: $image }) {
name
description
slug
availability
image
}
}
`;
const variables = {
name: "New Product",
description: "This is a description of the new product.",
slug: "new-product",
availability: true,
image: "https://example.com/new-product.jpg"
};
request(endpoint, graphQLMutation, variables)
.then((data) => console.log(data))
.catch((error) => console.error(error));

Start building with Node.js

We made it really easy to set up your project in Hygraph and use our GraphQL API within your Node.js project.

Quickstart

Check out our docs to see how you can quickly set up your Hygraph project and enable the content API for your Node.js website or app.

Learn GraphQL

Hygraph is GraphQL-native Headless CMS offers precise data retrieval, minimizing over-fetching and optimizing efficiency.

Examples

Look at some of the example projects to see Hygraph in action.

Why Hygraph

Choosing Hygraph for your Node.js project

Utilizing a GraphQL-native headless CMS with a Node.js application offers a symbiotic benefit; developers gain precise control over data retrieval, optimizing app performance with GraphQL's efficient queries, while content editors enjoy an intuitive management interface, allowing for seamless content updates and real-time reflection in the application.

This streamlined workflow enhances productivity, ensuring a smoother development process and a more dynamic content management experience, making it a robust solution for modern web applications.

nodejs cms

Developer Experience

We try to be the most un-opinionated CMS on the market with a wide collection of open source example projects to get you started.

Headless CMS

As a headless CMS (i.e. API based content management), you can be as modular and flexible as you need. We even support multiplatform content management.

Management API

Hygraph boasts a flexible and powerful management API to manage your content and schema, as well as a blazing fast content API.

Get started for free, or request a demo to discuss larger projects