
Product
Reachability for Ruby Now in Beta
Reachability analysis for Ruby is now in beta, helping teams identify which vulnerabilities are truly exploitable in their applications.
@hygraph/hygraph-astro-loader
Advanced tools
A package for loading Hygraph content into Astro's Content Collection API
Beta build of this project. Please report any issues.
A package to add a Hygraph loader to your Astro project. For more information on Astro Content Loaders, see the Astro's deep dive on Content Loaders.
npm install @hygraph/astro-content-loader
Before using the loader, you need to set up or collect the follwing from your Hygraph project:
token property.Once that's done, you're ready to set things up in Astro.
In your /content directory, add a config.ts file if it doesn't already exist with the following content:
import { HygraphLoader } from '@hygraph/astro-content-loader';
const pages = defineCollection({
loader: HygraphLoader({
endpoint: 'MY_API_ENDPOINT',
operation: 'pages',
fields: ["id", "title", "slug", { "body": ["text"] }],
}),
schema: z.object({
id: z.string(),
title: z.string({ required_error: 'Title is required' }).min(1, { message: 'Title is required to be at least 1 character' } ),
slug: z.string(),
body: z.object({
text: z.string(),
}),
})})
export const collections = { pages };
The pages collection will now be available in your Astro project. It can be accessed both as data in frontmatter, but also to create pages or respond to params.
---
import { getCollection } from 'astro:content';
export async function getStaticPaths() {
const pages = await getCollection('pages');
return pages.map(page => ({
params: { slug: page.slug },
props: { page },
}));
}
const { page } = Astro.props;---
---
<h1>{page.title}</h1>
<div>{page.body.text}</div>
| Property | Description | Required |
|---|---|---|
endpoint | The endpoint of your Hygraph API. | required |
operation | The operation to perform on the API. (listed in Hygraph as Plural API ID) | required |
fields | Array fields to fetch from the API. | required |
token | Optional token to pass to the API. | optional |
variables | Optional variables to pass to the GraphQL API | optional |
Validating the schema is optional, but recommended. The schema is used to validate the data returned from the API. Use Zod to define the schema of what you expect from the API.
Use one of these starters to get started with Hygraph and Astro:
FAQs
A package for loading Hygraph content into Astro's Content Collection API
We found that @hygraph/hygraph-astro-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Reachability analysis for Ruby is now in beta, helping teams identify which vulnerabilities are truly exploitable in their applications.

Research
/Security News
Malicious npm packages use Adspect cloaking and fake CAPTCHAs to fingerprint visitors and redirect victims to crypto-themed scam sites.

Security News
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.