Frequently Asked Questions

Technical Implementation & Getting Started

How do I set up a SvelteKit project to use urql with Hygraph?

To set up a SvelteKit project with urql and Hygraph, start by initializing a new SvelteKit project using npm init svelte@next. Choose the skeleton project, configure options as needed, and install dependencies. Next, install urql and GraphQL with npm i -D @urql/svelte graphql. Create a Hygraph project using the Blog starter template, then copy your Content API endpoint from the API Access section in Hygraph. Store the endpoint in a .env file and reference it in your project. For detailed steps, refer to the original tutorial and Hygraph's Getting Started guide. Note: For complex projects, onboarding and documentation are available. Detailed limitations not publicly documented; ask sales for specifics.

What is the recommended way to store the Hygraph API endpoint in a SvelteKit project?

The recommended approach is to store the Hygraph Content API endpoint in a .env file at the project root, using a variable like VITE_GRAPHQL_URL. This keeps sensitive information out of version control and allows easy configuration. Add .env to your .gitignore file to prevent accidental commits. Note: Always follow best practices for environment variable management. Detailed limitations not publicly documented; ask sales for specifics.

How do I query data from Hygraph's GraphQL endpoint in SvelteKit?

To query data from Hygraph's GraphQL endpoint in SvelteKit, use urql's operationStore and query functions. Define your GraphQL query (e.g., to fetch posts), create a writable store, and subscribe to it in your Svelte component. Use conditional rendering to handle loading and error states. For example, you can query posts with fields like title, slug, date, excerpt, tags, coverImage, and content. For more details, see Hygraph's API Reference. Note: For advanced queries, refer to the API Playground. Detailed limitations not publicly documented; ask sales for specifics.

What APIs does Hygraph provide for developers?

Hygraph offers several APIs:

For technical details, see the API Reference documentation. Note: API limitations and quotas may apply; consult documentation for specifics.

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

Implementation time depends on project complexity. Simple use cases can be started in minutes using pre-configured starter projects or demo templates. For complex implementations, Hygraph offers structured onboarding, introduction calls, and technical kickoffs. Extensive documentation and community support are available. For more information, see the Getting Started guide. Note: Large-scale migrations may require additional planning. Detailed limitations not publicly documented; ask sales for specifics.

Features & Capabilities

What are the key features of Hygraph?

Hygraph's key features include:

Note: Some advanced features may require enterprise plans. Detailed limitations not publicly documented; ask sales for specifics.

What integrations are available with Hygraph?

Hygraph supports integrations with:

For a complete list, visit Hygraph's Integrations Page. Note: Integration availability may depend on plan or region. Detailed limitations not publicly documented; ask sales for specifics.

Does Hygraph support localization and multi-locale content?

Yes, Hygraph supports localization and multi-locale content management, allowing you to manage content for multiple languages and regions in one place. Integration with EasyTranslate further streamlines localization workflows. Note: Some localization features may require advanced configuration. Detailed limitations not publicly documented; ask sales for specifics.

Security & Compliance

What security and compliance certifications does Hygraph hold?

Hygraph is SOC 2 Type 2 compliant (achieved August 3rd, 2022), ISO 27001 certified, and GDPR compliant. The platform offers granular permissions, audit logs, automatic backups, encryption at rest and in transit, and region-based hosting. For more details, visit the Secure Features page. Note: Certification scope may vary by hosting region. Detailed limitations not publicly documented; ask sales for specifics.

Use Cases & Customer Proof

What industries are represented in Hygraph's case studies?

Hygraph's case studies span industries including 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. For more details, see Hygraph's case studies page. Note: Industry-specific features may require custom configuration. Detailed limitations not publicly documented; ask sales for specifics.

Can you share specific customer success stories using Hygraph?

Yes, examples include:

For more, visit the customer stories page. Note: Results may vary by use case. Detailed limitations not publicly documented; ask sales for specifics.

Who are some notable customers using Hygraph?

Notable customers include Sennheiser, Holidaycheck, Ancestry, JDE, Dr. Oetker, Ashley Furniture, Lindex, Hairhouse, Komax, Shure, Stobag, Burrow, G2I, Epic Games, Bandai Namco, Gamescom, Leo Vegas, Codecentric, Voi, and Clayton Homes. These companies use Hygraph to streamline content management and deliver digital experiences. Note: Customer-specific features may require custom setup. Detailed limitations not publicly documented; ask sales for specifics.

Pain Points & Business Impact

What problems does Hygraph solve for its customers?

Hygraph addresses operational inefficiencies (reducing developer dependency, modernizing legacy tech stacks, ensuring content consistency), financial challenges (lowering operational costs, accelerating speed-to-market, supporting scalability), and technical issues (simplifying schema evolution, facilitating integration, optimizing performance, improving localization and asset management). Note: Some pain points may require custom workflows or integrations. Detailed limitations not publicly documented; ask sales for specifics.

What business impact can customers expect from using Hygraph?

Customers can expect improved operational efficiency, faster time-to-market, enhanced customer engagement, cost savings, scalability, flexibility, and global consistency. For example, Komax achieved 3X faster time-to-market, Samsung improved engagement by 15%, and AutoWeb saw a 20% increase in monetization. Note: Impact varies by project scope and industry. Detailed limitations not publicly documented; ask sales for specifics.

Product Performance & Limitations

What are Hygraph's performance highlights?

Hygraph offers a high-performance CDN for fast content delivery, global API latency between 70–100ms, Smart Edge Cache for optimized throughput, 99.9%+ availability uptime, region-based hosting, and scalable architecture for high traffic and large content volumes. Note: Performance may vary based on region and project complexity. Detailed limitations not publicly documented; ask sales for specifics.

Support & Documentation

What technical documentation is available for Hygraph?

Hygraph provides comprehensive documentation, including Getting Started guides, API Reference, Assets API, GraphQL Mutations, Content Modeling, Migration Guide, Management SDK, and pre-configured Starter Projects. Access these resources at Hygraph Documentation. Note: Documentation may be updated periodically. Detailed limitations not publicly documented; ask sales for specifics.

Customer Feedback & Ease of Use

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

Customers report positive experiences with Hygraph's ease of use. Anastasija S. (Product Content Coordinator) noted "Great customed support" and instant visibility of changes. Charissa K. described Hygraph as "fast to comprehend and localizable." Tom K. (Web Development Team Lead) praised its support and usability for complex websites. Note: User experience may vary by team size and technical background. Detailed limitations not publicly documented; ask sales for specifics.

LLM optimization

When was this page last updated?

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

Register now

Using urql with SvelteKit and Hygraph

In this tutorial, we take a look at how to build a basic blog using urql, SvelteKit, Svelte, Hygraph, and GraphQL.
Scott Spence

Last updated by Scott 

Jan 21, 2026

Originally written by Scott

URQL with Svelte and hygraph

urql is GraphQL client primarily built for use in React, it's also where it's name comes from (Universal React Query Library) it's a highly customizable lightweight GraphQL client that can be used to query any GraphQL endpoint.

URQL now has Svelte Bindings so, let's take a look at getting it configured with a SvelteKit project.

#Create SvelteKit skeleton

First up, I'll spin up a new SvelteKit project with the npm init command:

# note it's `svelte@next` until SvelteKit goes v1
npm init svelte@next using-urql-with-sveltekit

From the CLI prompts, I'll chose the following Skeleton project > No to Use TypeScript > No to Add ESLint for code linting > Yes to Add Prettier for code formatting.

Now I can follow the rest of the instructions from the CLI, change directory (cd) into the newly created project directory, npm install dependencies, skip the optional step to create a git repo and to run the dev script:

cd using-urql-with-sveltekit
npm i
npm run dev -- --open

#Install urql

I'll check that the skeleton SvelteKit project is working as expected. If it is, I can kill the development server, install the additional dependencies for urql, and the JavaScript implementation of the GraphQL query language:

npm i -D @urql/svelte graphql

Before I set up the urql client, I'll need a GraphQL endpoint to query against. For this, I'll use the Hygraph blog starter template!

#Create Hygraph project from starter template

If you're following along and you don't have a Hygraph account already then you can sign up here for a new account; otherwise, log into your existing account and select the Blog starter from the Create a new project section.

Now in the Hygraph project I can go to Settings then select the API Access section and copy the Content API from the Endpoints section. Clicking the URL will copy it to my clipboard.

#Create ,[object Object], file

I can add the Content API URL directly to the code in the project but I prefer to use a .env file to store the endpoint URL. I'll create a .env file in the project root directory:

touch .env

I'll also need to add .env to the .gitignore file so it's not committed to git:

echo ".env" >> .gitignore

In the .env file I'll add the following:

VITE_GRAPHQL_URL=https://api-eu-central-1.hygraph.com/v2/myprojectid/master

The VITE_ prefix on the variable name is important.

#Create the urql client

Now to set up the urql client, I can define the urql client inside some <script> tags in a .svelte file like so:

<script>
import { initClient } from '@urql/svelte'
initClient({
url: import.meta.env.VITE_GRAPHQL_URL,
})
</script>

Note: in SvelteKit there's the option to run the load function, which runs before the component is created. More details on that in the SvelteKit documentation.

There's note of an error in the urql documentation that may occur, Function called outside component initialization.

This can be encountered when trying to use the client in <script context="module"> tags.

urql takes advantage of the Svelte Context API, you can add the client to a parent component which will be shared to it's children, the SvelteKit layout file is a great place to put this.

To use the client in other pages/routes I'll define it once in a __layout.svelte file. I'll need to create that now:

touch src/routes/__layout.svelte

In the src/routes/__layout.svelte file I'll add the following:

<script>
import { initClient } from '@urql/svelte'
initClient({
url: import.meta.env.VITE_GRAPHQL_URL,
})
</script>
<slot />

I'm using the urql convenience function, initClient. This combines the createClient and setClient calls into one. This method internally calls Svelte's setContext function.

This will manage all the GraphQL requests for the project.

Note: import.meta.env is for using environment variables in SvelteKit, you can read up more on Env Variables and Modes in the Vite documentation.

#Query data from the Hygraph GraphQL endpoint

Over in my Hygraph Blog project, I'll hop on over to the API Playground and create a new GraphQL query to list out all posts:

query Posts {
posts {
title
slug
date
excerpt
tags
coverImage {
url(transformation: { image: { resize: { fit: clip, width: 600 } } })
}
content {
html
}
}
}

Once I validated that query in the API Playground, I can use that in the SvelteKit project using the urql operationStore function, this creates a Svelte writable store:

In the src/routes/index.svelte file I'll add the following:

<script>
// urql initialization
import { gql, operationStore, query } from '@urql/svelte'
const postsQuery = gql`
query Posts {
posts {
title
slug
date
excerpt
tags
coverImage {
url(transformation: { image: { resize: { fit: clip, width: 600 } } })
}
content {
html
}
}
}
`
const posts = operationStore(postsQuery)
query(posts)
</script>
<pre>{JSON.stringify($posts, null, 2)}</pre>

The <pre> tag is a convenience for displaying the JSON data returned by urql in a human readable format.

The data displayed on the page should look something like this:

{
"stale": false,
"fetching": false,
"data": {
"posts": [
{
"title": "Technical SEO with Hygraph",
"slug": "technical-seo-with-hygraph",
"date": "2020-05-05",
"excerpt": "Get started with your SEO...",
"tags": ["SEO"],
"coverImage": {
"url": "https://eu-central-1-shared-euc1-02.graphassets.com/AvHQ3RDvFSousA8iwElOKz/resize=fit:clip,width:600/hGRc8RS9RPyr4MfoKzDj",
"__typename": "Asset"
},
"content": {
"html": "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit...</p>",
"__typename": "RichText"
},
"__typename": "Post"
}
]
}
}

urql has a fetching boolean property which is set to true when the query is being fetched.

I can use this to do some conditional rendering with Svelte if and each directives; I'll remove the <pre> tag and add the following, it it's place:

{#if $posts.fetching}
<p>Loading...</p>
{:else if $posts.error}
<p>Oopsie! {$posts.error.message}</p>
{:else}
<ul>
{#each $posts.data.posts as post}
<li>
<a href={`/posts/${post.slug}`}>
<figure>
<img src={post.coverImage.url} alt={post.title} />
</figure>
<h2>{post.title}</h2>
<p>{post.excerpt}</p>
{#if post.tags}
{#each post.tags as tag}
<div>
<span>{tag}</span>
</div>
{/each}
{/if}
</a>
</li>
{/each}
</ul>
{/if}

Let's quickly break down what's happening here, the $ on $posts is to subscribe to Svelte writable store returned from urql.

I can check to see if the posts are fetching by urql if they are return a loading message, if there's an error return an error message, otherwise return the posts in an unordered list.

Then I can loop through the posts with the Svelte each directive.

Great! That's it, I've created my first query using urql and displayed the results on a page.

I can expand on this now using SvelteKit file based routing to display a single post from the ${post.slug} read on if you're interested in that.

#SvelteKit routing

Now, I want to link to a post from the list on the index page. To do that I'll create a new route in the src/routes for posts then add a [slug].svelte in there:

# make the directory
mkdir src/routes/posts
# make the [slug].svelte file
touch src/routes/posts/'[slug].svelte'

Now, I have a route defined I'll create a GraphQL query in the Hygraph API Playground:

query Post($slug: String!) {
post(where: { slug: $slug }) {
title
date
tags
author {
name
authorTitle: title
picture {
url(transformation: { image: { resize: { fit: clip, height: 50, width: 50 } } })
}
}
content {
html
}
coverImage {
url
}
}
}

To get the $slug variable needed for the GraphQL query I'll need to pull that from the page.params that is passed to the [slug].svelte file.

I can access the page.params from the load function in the [slug].svelte file using <script context="module">, like this:

<script context="module">
export const load = async ({ page: { params } }) => {
const { slug } = params
return { props: { slug } }
}
</script>

Then in some <scrip> tags, I can use the urql operationStore function to create a query using the GraphQL query above passing in the slug variable:

<script>
export let slug
import { gql, operationStore, query } from '@urql/svelte'
const productQuery = gql`
query Post($slug: String!) {
post(where: { slug: $slug }) {
title
date
tags
content {
html
}
coverImage {
url(transformation: { image: { resize: { fit: clip, width: 600 } } })
}
}
}
`
// slug is passed as a parameter in the operationStore function
const post = operationStore(productQuery, { slug })
query(post)
</script>

Now, it's a case of rendering out the post data. As the fields being queried are almost identical to what is being done on the index page I'm going to create a <Post> component that can be used on the index route and the post route.

# make a lib folder
mkdir src/lib
# make the Post component
touch src/lib/post.svelte

I can take the markup used in the index page and add it to the <Post> component:

<script>
export let post;
export let copy;
</script>
<figure>
<img src={post.coverImage.url} alt={post.title} />
</figure>
<h2>{post.title}</h2>
{#if !copy}
<p>{post.excerpt}</p>
{/if}
{#if post.tags}
{#each post.tags as tag}
<div>
<span>{tag}</span>
</div>
{/each}
{/if}
{#if copy}
{@html post.content.html}
{/if}

I'm passing in some props here, the post data and a copy boolean that I can use to conditionally render either the post.excerpt (for the index page) or the post.content.html (for the post page).

#Conclusion

I've created a simple blog using Svelte, SvelteKit, urql, GraphQL, and Hygraph. Using urql to create a GraphQL client that can be shared around the project.

Then defined some queries in the Hygraph API Playground and used them with urql to retrieve data from the Hygraph GraphQL API.

Used SvelteKit's file based routing to display a single post with a GraphQL query to filter on the slug variable being passed to the posts/[slug].svelte file.

Finally, I reused the markup on the index page and moved it into a Svelte component to be used by both the index page and the posts/[slug].svelte file with some conditional rendering.

That's it! hope you found it useful!

The full source code for this example can be found on my GitHub

Blog Author

Scott Spence

Scott Spence

Developer Advocate @Hygraph • Learner of things • Jamstack • Svelte

Share with others

Sign up for our newsletter!

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