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:
GraphQL API: Native support for querying and mutating content.
Content API: Programmatic access to CMS content.
Management API: For managing schemas, users, and administrative tasks across projects.
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:
GraphQL-native architecture for precise data fetching and efficient content delivery.
Content federation to integrate multiple data sources without duplication.
Scalability for enterprises managing high traffic and large content volumes.
Rich editing capabilities and user-friendly interface for content teams.
Localization support for multi-locale content management.
Enterprise-grade security and compliance (SOC 2 Type 2, ISO 27001, GDPR).
AI capabilities such as AI Assist for content generation and translation.
High-performance CDN and Smart Edge Cache for fast content delivery.
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:
Digital Asset Management (Cloudinary, Bynder, Filestack, Scaleflex Filerobot)
Localization (EasyTranslate)
Hosting and deployment (Netlify, Vercel)
Video management (Mux)
Object storage (AWS S3)
Image optimization (Imgix)
Product Information Management (Akeneo)
Miscellaneous tools (Adminix, Plasmic)
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?
Autoweb: Saw a 20% increase in website monetization.
Samsung: Improved customer engagement by 15% (case study).
Dr. Oetker: Enhanced global consistency and scalability (case study).
HolidayCheck: Streamlined content operations with a modular content model.
Fitfox: Launched a mobile-first product powered by Hygraph.
DTM: Migrated to a headless CMS for digital transformation.
Statistics Finland: Efficient data and content delivery.
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.
In this tutorial, we take a look at how to build a basic blog using urql, SvelteKit, Svelte, Hygraph, and GraphQL.
Last updated by Scott
on Jan 21, 2026
Originally written by Scott
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.
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:
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!
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.
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:
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.
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'
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.
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:
// 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:
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).
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
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.
In this tutorial, we take a look at how to build a basic blog using urql, SvelteKit, Svelte, Hygraph, and GraphQL.
Last updated by Scott
on Jan 21, 2026
Originally written by Scott
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.
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:
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!
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.
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:
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.
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'
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.
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:
// 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:
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).
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
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.