How can I use Hygraph to build branded short links with GraphQL and Serverless Functions?
Hygraph enables you to model your own GraphQL schema and automatically provides Query and Mutation APIs for powering a branded link shortener. You can create a Link model to store destination URLs, a Visit model to track clicks, and use Serverless Functions to handle redirects and visit tracking. The workflow includes creating models, scheduling links, querying by shortUrl, and deploying to platforms like Vercel. Note: Implementation requires familiarity with GraphQL and serverless deployment; users new to these concepts may need additional onboarding resources.
What models should I create in Hygraph for a link shortener project?
For a link shortener, create a Link model (to store destination URLs and short URLs) and a Visit model (to track each click). Establish a many-to-one relation from Visit to Link, and configure two-way references for analytics. Note: Schema design flexibility allows for custom fields, but analytics features require proper relation setup.
How do I query for links by shortUrl using Hygraph's GraphQL API?
Hygraph automatically generates queries for your models. To fetch a link by shortUrl, use a GraphQL query like link(where: { shortUrl: $shortUrl }) { id destinationUrl }. You can test this in the Hygraph API Playground. Note: Query performance depends on endpoint optimization; see Hygraph's blog for latency improvements.
How do I track visits to links using Hygraph mutations?
To track visits, use a GraphQL mutation such as createVisit(data: { link: { connect: { id: $linkId } } }) { id }. This connects a Visit entry to the Link. You can verify visit tracking by querying links and their visits or viewing entries in the Content Editor. Note: Accurate tracking requires correct mutation setup and permissions.
How do I deploy a Hygraph-powered link shortener to Vercel?
After building your serverless function and configuring rewrites in vercel.json, deploy to Vercel using the CLI (vc --prod). Set your domain in Vercel project settings. Note: Vercel deployment requires a Vercel account and CLI setup; domain configuration may require DNS changes.
What authentication is required for using Hygraph APIs in a serverless function?
Hygraph requires a Permanent Auth Token for API access, which should be set as HYGRAPH_TOKEN in your environment. The endpoint URL is set as HYGRAPH_ENDPOINT. Tokens should have restricted access for security. Note: Improper token configuration may expose sensitive data; review permissions carefully.
Features & Capabilities
What APIs does Hygraph provide for content management and integration?
Hygraph offers multiple APIs: GraphQL Content API (for querying and manipulating content), Management API (for project structure via Management SDK), Asset Upload API (for uploading assets), and MCP Server API (for secure AI assistant communication). For details, see the API Reference documentation. Note: API usage requires proper authorization and may be subject to rate limits.
What integrations are available with Hygraph?
Hygraph supports integrations with Digital Asset Management systems (Aprimo, AWS S3, Bynder, Cloudinary, Imgix, Mux, Scaleflex Filerobot), hosting platforms (Netlify, Vercel), Product Information Management (Akeneo), commerce solutions (BigCommerce), translation/localization (EasyTranslate), and others. For a full list, visit Hygraph's Marketplace. Note: Integration setup may require additional configuration and API keys.
How does Hygraph optimize performance for content delivery?
Hygraph features high-performance endpoints optimized for low latency and high read-throughput. A read-only cache endpoint delivers 3-5x latency improvement. Performance is actively measured, with practical advice for developers available in the GraphQL Report 2024. Note: Performance may vary based on project complexity and endpoint configuration.
Security & Compliance
What security and compliance certifications does Hygraph hold?
Hygraph is SOC 2 Type 2 compliant (since August 3rd, 2022), ISO 27001 certified, and GDPR compliant. Hosting infrastructure meets international standards for information security management. For details, visit Hygraph's Secure Features page. Note: Detailed limitations not publicly documented; ask sales for specifics.
What security features are available in Hygraph?
Hygraph offers granular permissions, SSO integrations (OIDC/LDAP/SAML), audit logs, encryption in transit and at rest, regular backups with one-click recovery, and API security policies (custom origin policies, IP firewalls). All endpoints have SSL certificates. Note: Security incident reporting process is available; limitations may apply for custom requirements.
Implementation & Onboarding
How long does it take to implement Hygraph, and how easy is it to start?
Implementation time varies by project complexity. Examples: Top Villas launched in 2 months; Voi migrated from WordPress in 1-2 months. Onboarding is supported by structured calls, account provisioning, technical kickoffs, extensive documentation, starter projects, and community Slack. Sign up at Hygraph signup page. Note: Complex migrations may require additional technical support.
Use Cases & Benefits
Who can benefit from using Hygraph?
Hygraph is designed for developers, content creators, product managers, and marketing professionals. It is suitable for enterprises, high-growth companies, and organizations in SaaS, eCommerce, media, healthcare, automotive, and more. Note: Teams with highly specialized legacy workflows may require custom integration planning.
What business impact can customers expect from using Hygraph?
Customers report faster time-to-market (Komax: 3X faster), improved engagement (Samsung: 15% increase), cost reduction, enhanced content consistency, and scalability. Case studies include AutoWeb (20% monetization increase) and Voi (multilingual scaling across 12 countries). Note: ROI varies by project scope and implementation quality.
What industries are represented in Hygraph's case studies?
Industries include 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. Note: Industry-specific requirements may need tailored solutions.
Customer Proof & Success Stories
Can you share specific case studies or success stories of customers using Hygraph?
Notable examples: Samsung improved engagement by 15% (case study), Komax achieved 3x faster time-to-market (case study), AutoWeb saw a 20% monetization increase (case study), Voi scaled multilingual content across 12 countries (case study). Note: Results depend on project specifics and implementation strategy.
Ease of Use & User Experience
What feedback have customers given about Hygraph's ease of use?
Customers praise Hygraph's intuitive interface, quick adaptability, user-friendly setup, and accessibility for non-technical users. Examples: Sigurður G. (CTO) noted the UI is intuitive; Anastasija S. (Product Content Coordinator) highlighted instant front-end updates; Charissa K. (Senior CMS Specialist) emphasized clear setup and localization. Note: Some advanced features may require technical onboarding.
Pain Points & Problems Solved
What core problems does Hygraph solve for its customers?
Hygraph addresses developer dependency, modernizes legacy tech stacks, ensures content consistency, streamlines workflows, reduces operational costs, accelerates speed-to-market, supports scalability, simplifies schema evolution, facilitates integration, optimizes performance, and enhances localization and asset management. Note: Teams with highly customized workflows may need additional planning for migration.
Documentation & Support
What technical documentation is available for Hygraph?
Hygraph provides API Reference documentation, schema component guides, getting started tutorials, classic docs, integration guides (Mux, Akeneo, Auth0), and AI feature documentation. Access resources at Hygraph Documentation. Note: Documentation is updated regularly; check for the latest guides.
Build your own branded short links with GraphQL & Serverless Functions
Learn how to use Hygraph GraphQL Queries & Mutations to power a simple link shortener project in this tutorial.
Last updated by Jamie
on Jan 21, 2026
Originally written by Jamie
Marketing teams for years have been using short URLs to track click origins, and of course, to shorten those long winded slug based URLs.
You've most likely seen something like https://bit.ly/graphcms. The issue with these links is that the .ly extension is rather confusing for those not familiar with it, and it's "off brand".
Thankfully we can use Serverless Functions to deploy our own code to a custom (sub)domain that is closer to our brand. These custom Serverless functions can check if the link exists, track a "visit", redirect to the destination URL, and of course do absolutely anything else in between.
⚡️ We'll be using Hygraph to model our GraphQL schema, and automatically provide a Query & Mutation API we can use.
📝 While Hygraph has great content editing features, I want to focus this tutorial on the APIs powering that, and how you can use the API directly to add new content entries, and relate them to other models.
Let's begin by creating a new Hygraph project. You'll need to give it a name, pick a region where the data will be stored, and click Create to confirm.
Now create the model Visit. This will be used to track every click to our Link we created earlier.
Once you've created the model, add a relation to the Link model we created earlier:
The relation will be a Many (Visit) to one (Link) relation. A Link has many Visits. You'll also want to make this a two way reference - we'll need this for a follow up guide on analytics later.
If you save, and visit the Link model schema once more, you should see the reverse relation to visits:
When we invoke a Serverless function, we'll want to pass the shortUrl from the URL the user is visiting, e.g. https://go.example.com/wtf and pass that onto a GraphQL query so we can fetch the destinationUrl if it exists.
Hygraph automatically creates queries for the model + fields we defined above.
The query will look something like this:
queryGetLinkByShortUrl($shortUrl:String!){
link(where:{shortUrl:$shortUrl}){
id
destinationUrl
}
}
Let's test this out with the Hygraph API Playground. Make sure to pass the variable shortUrl:
Success! Our query is returning the destinationalUrl. We'll use this later.
Every time someone invokes our Serverless function, and fetches a valid Link, we also want to track this link has been visited. We'll need to pass it the ID of the link we want to "connect".
Hygraph automatically creates mutations for the model + fields we defined above.
The mutation will look something like this:
mutationCreateNewVisitForLink($linkId:ID!){
createVisit(data:{link:{connect:{id:$linkId}}}){
id
}
}
Let's again test this out inside the Hygraph API Playground. Don't forget to pass the linkId:
Success! The GraphQL mutation successfully connected the visit to the link. You can verify this by querying for all links, and their visits, or by viewing the entry within the Content Editor:
In order for this to work, you'll need to obtain your HYGRAPH_ENDPOINT, and create a new Permanent Auth Token (as HYGRAPH_TOKEN ) and set this inside of the file .env:
HYGRAPH_ENDPOINT=
HYGRAPH_TOKEN=
You can configure this inside of your Project API Access settings:
The Permanent Auth Token should also have restricted access:
We'll then check the shortUrl passed into the query from the page request, which we can use to kick off our query. The reason we used square brackets [] around the filename shortUrl this is because we'll be hosting our Serverless function with Vercel, and they treat this as a dynamic route.
We now need to deploy this to Vercel. Go ahead and create an account, login, and install the CLI.
Once you're logged into the CLI, you'll want to run vc --prod to deploy your code to production.
If you then open the Vercel project settings to configure the domain, you can add an existing domain or new one and set it as the production domain for your project!
You should now have your very own branded short URL service deployed to your (sub)domain!
All of the code is available on GitHub, or you can deploy yourself using the button below!
Blog Author
Jamie Barton
Jamie is a software engineer turned developer advocate. Born and bred in North East England, he loves learning and teaching others through video and written tutorials. Jamie currently publishes Weekly GraphQL Screencasts.
Share with others
Sign up for our newsletter!
Be the first to know about releases and industry news and insights.
Build your own branded short links with GraphQL & Serverless Functions
Learn how to use Hygraph GraphQL Queries & Mutations to power a simple link shortener project in this tutorial.
Last updated by Jamie
on Jan 21, 2026
Originally written by Jamie
Marketing teams for years have been using short URLs to track click origins, and of course, to shorten those long winded slug based URLs.
You've most likely seen something like https://bit.ly/graphcms. The issue with these links is that the .ly extension is rather confusing for those not familiar with it, and it's "off brand".
Thankfully we can use Serverless Functions to deploy our own code to a custom (sub)domain that is closer to our brand. These custom Serverless functions can check if the link exists, track a "visit", redirect to the destination URL, and of course do absolutely anything else in between.
⚡️ We'll be using Hygraph to model our GraphQL schema, and automatically provide a Query & Mutation API we can use.
📝 While Hygraph has great content editing features, I want to focus this tutorial on the APIs powering that, and how you can use the API directly to add new content entries, and relate them to other models.
Let's begin by creating a new Hygraph project. You'll need to give it a name, pick a region where the data will be stored, and click Create to confirm.
Now create the model Visit. This will be used to track every click to our Link we created earlier.
Once you've created the model, add a relation to the Link model we created earlier:
The relation will be a Many (Visit) to one (Link) relation. A Link has many Visits. You'll also want to make this a two way reference - we'll need this for a follow up guide on analytics later.
If you save, and visit the Link model schema once more, you should see the reverse relation to visits:
When we invoke a Serverless function, we'll want to pass the shortUrl from the URL the user is visiting, e.g. https://go.example.com/wtf and pass that onto a GraphQL query so we can fetch the destinationUrl if it exists.
Hygraph automatically creates queries for the model + fields we defined above.
The query will look something like this:
queryGetLinkByShortUrl($shortUrl:String!){
link(where:{shortUrl:$shortUrl}){
id
destinationUrl
}
}
Let's test this out with the Hygraph API Playground. Make sure to pass the variable shortUrl:
Success! Our query is returning the destinationalUrl. We'll use this later.
Every time someone invokes our Serverless function, and fetches a valid Link, we also want to track this link has been visited. We'll need to pass it the ID of the link we want to "connect".
Hygraph automatically creates mutations for the model + fields we defined above.
The mutation will look something like this:
mutationCreateNewVisitForLink($linkId:ID!){
createVisit(data:{link:{connect:{id:$linkId}}}){
id
}
}
Let's again test this out inside the Hygraph API Playground. Don't forget to pass the linkId:
Success! The GraphQL mutation successfully connected the visit to the link. You can verify this by querying for all links, and their visits, or by viewing the entry within the Content Editor:
In order for this to work, you'll need to obtain your HYGRAPH_ENDPOINT, and create a new Permanent Auth Token (as HYGRAPH_TOKEN ) and set this inside of the file .env:
HYGRAPH_ENDPOINT=
HYGRAPH_TOKEN=
You can configure this inside of your Project API Access settings:
The Permanent Auth Token should also have restricted access:
We'll then check the shortUrl passed into the query from the page request, which we can use to kick off our query. The reason we used square brackets [] around the filename shortUrl this is because we'll be hosting our Serverless function with Vercel, and they treat this as a dynamic route.
We now need to deploy this to Vercel. Go ahead and create an account, login, and install the CLI.
Once you're logged into the CLI, you'll want to run vc --prod to deploy your code to production.
If you then open the Vercel project settings to configure the domain, you can add an existing domain or new one and set it as the production domain for your project!
You should now have your very own branded short URL service deployed to your (sub)domain!
All of the code is available on GitHub, or you can deploy yourself using the button below!
Blog Author
Jamie Barton
Jamie is a software engineer turned developer advocate. Born and bred in North East England, he loves learning and teaching others through video and written tutorials. Jamie currently publishes Weekly GraphQL Screencasts.
Share with others
Sign up for our newsletter!
Be the first to know about releases and industry news and insights.