Frequently Asked Questions

File Uploads & Integration with React Dropzone

How can I upload files to Hygraph using React Dropzone?

You can upload files to Hygraph by integrating React Dropzone in your frontend application. React Dropzone allows users to drag and drop files, which you can then send to a backend proxy server. The proxy server securely forwards the files to your Hygraph project's asset upload endpoint. This process ensures that your Permanent Auth Token is not exposed on the client side. For detailed steps and code samples, refer to the original blog post and Hygraph's asset upload documentation.

What is the recommended way to securely upload files to Hygraph from a frontend application?

The recommended approach is to use a backend proxy server. Your frontend (e.g., React Dropzone) sends the file to your backend, which then uses a Permanent Auth Token to upload the file to Hygraph. This prevents exposing sensitive credentials in the browser. You can use frameworks like Express with packages such as multer, form-data, and node-fetch to implement this proxy. See the blog's code samples for a quickstart example.

What endpoint should I use to upload files to Hygraph?

To upload files to Hygraph, append /upload to your project API endpoint. The format is: https://[region].hygraph.com/v2/[projectId]/[environment]/upload. You can upload files directly or by remote URL, and they will be stored as assets within your Hygraph project. For more details, see the Hygraph documentation.

How do I use a Permanent Auth Token for uploads, and what are the security considerations?

It's best to create a dedicated Permanent Auth Token for uploads. However, you should never expose this token on the client side. Always use a backend proxy to handle uploads securely. If the token is exposed, anyone could upload files to your project. For more on authorization, see Hygraph's authorization docs.

Can I upload files to Hygraph by remote URL?

Yes, you can upload files to Hygraph by providing a remote URL of an asset hosted elsewhere. Use a POST request to the /upload endpoint with the remote URL in the body. This is useful for server-side integrations and automated workflows. See the blog post for code examples.

How do I restrict accepted file types when using React Dropzone with Hygraph?

You can restrict accepted file types by specifying the accept property in the useDropzone hook. For example, to accept only images, use accept: "image/*". This ensures users can only upload allowed file types to Hygraph.

What backend technologies can I use to create a proxy for Hygraph uploads?

You can use Node.js with Express, along with packages like multer (for handling file uploads), form-data, and node-fetch to create a backend proxy. This proxy receives files from the frontend and securely uploads them to Hygraph. The blog provides a quickstart example using these technologies.

How do I preview uploaded files in my React application before sending them to Hygraph?

You can use URL.createObjectURL to generate a preview of each file in your React state. Store the files in a state variable and map over them to display previews. Remember to revoke object URLs using URL.revokeObjectURL in a useEffect cleanup to avoid memory leaks.

Where can I find a complete example of integrating React Dropzone with Hygraph uploads?

You can find a complete example, including both frontend and backend code, in the Hygraph GitHub repository at with-upload-proxy. This example demonstrates how to set up a proxy server and connect it with a React Dropzone frontend.

How do I configure Create React App to proxy upload requests to my backend server?

In your package.json file, add a proxy field pointing to your backend server's URL (e.g., "proxy": "http://localhost:4000"). This allows your React app to forward API requests to the backend during development, simplifying local testing of file uploads.

What are the best practices for managing environment variables in a Hygraph upload integration?

Store sensitive values like your Hygraph endpoint and Permanent Auth Token in environment variables. Use packages like dotenv to load these variables in development. Never hardcode credentials in your codebase or expose them to the frontend.

Can I use Hygraph to manage assets uploaded from different sources?

Yes, Hygraph supports uploading assets both directly from your application and via remote URLs. All uploaded files are stored as assets within your Hygraph project, making it easy to manage and deliver digital assets across channels. For more, see the assets overview.

What is the maximum file size for uploads in Hygraph?

The maximum file size for uploads depends on your Hygraph plan. For example, the Hobby plan allows up to 50MB per asset upload, while the Growth plan increases this to 200MB. For custom limits, the Enterprise plan offers tailored options. See the Hygraph pricing page for details.

Does Hygraph support asset upload via API for both new and legacy projects?

Yes, Hygraph provides an Asset Upload API for both new and legacy projects. Projects created before February 2024 use the Legacy asset system, while newer projects use the Hygraph Asset Management system. For more details, see the assets API documentation.

How do I handle errors during file uploads to Hygraph?

When uploading files via a backend proxy, handle errors by checking the response from Hygraph's upload endpoint. Return meaningful error messages to the frontend and log issues for debugging. The provided Express example in the blog demonstrates basic error handling for missing files and failed uploads.

Can I automate asset uploads to Hygraph from other services?

Yes, you can automate asset uploads to Hygraph by using server-side scripts or integrations that POST files or remote URLs to the Hygraph upload endpoint. This is useful for workflows like importing assets from external storage or third-party services.

What are the benefits of using Hygraph for asset management in React applications?

Hygraph provides a scalable, secure, and flexible platform for managing digital assets. Benefits include easy integration with React, robust API support, asset federation, and advanced features like localization and access control. This streamlines asset delivery and management for modern web applications.

How do I get started with Hygraph asset uploads if I'm new to the platform?

You can start by signing up for a free Hygraph account and exploring the API Playground. The documentation provides step-by-step guides for asset uploads, and you can use the provided code samples to quickly integrate uploads into your React application. Community support is available via Slack and webinars.

Where can I find more resources and documentation on Hygraph uploads?

Visit the Hygraph documentation for comprehensive guides on asset uploads, API usage, and integration best practices. Additional tutorials and examples are available on the Hygraph blog and GitHub.

What types of integrations does Hygraph support for asset management?

Hygraph supports integrations with popular Digital Asset Management (DAM) systems such as Aprimo, AWS S3, Bynder, Cloudinary, Imgix, Mux, and Scaleflex Filerobot. You can also build custom integrations using the SDK or connect external APIs via REST and GraphQL. Explore the Hygraph Marketplace for pre-built apps and more details in the Integrations Documentation.

Does Hygraph provide APIs for asset upload and management?

Yes, Hygraph offers multiple APIs for asset upload and management, including the Content API, High Performance Content API, Asset Upload API, and Management API. These APIs allow you to upload, query, and manage assets programmatically. See the API Reference Documentation for details.

What are the key security and compliance features of Hygraph for asset management?

Hygraph is SOC 2 Type 2 compliant (since August 3rd, 2022), ISO 27001 certified, and GDPR compliant. It offers enterprise-grade security features such as granular permissions, audit logs, SSO integrations, encryption at rest and in transit, and regular data backups. For more, visit the Secure features page.

How does Hygraph ensure high performance for asset delivery?

Hygraph provides high-performance endpoints designed for low latency and high read-throughput content delivery. The platform actively measures API performance and offers practical advice for optimization. For more, see the performance improvements blog and GraphQL Report 2024.

What are the pricing options for Hygraph asset management?

Hygraph offers three main pricing plans: Hobby (free forever, up to 50MB per asset), Growth (starts at $199/month, up to 200MB per asset), and Enterprise (custom pricing and limits). Each plan includes different features and support levels. See the pricing page for full details.

Who can benefit from using Hygraph for asset management and uploads?

Hygraph is ideal for developers, product managers, content creators, marketing professionals, and solutions architects in enterprises, agencies, eCommerce, media, technology, and global brands. Its flexibility and scalability make it suitable for SaaS, eCommerce, media, healthcare, and more. See case studies for examples.

What customer feedback has Hygraph received regarding ease of use for asset uploads?

Customers praise Hygraph for its intuitive user interface and ease of setup, even for non-technical users. The platform allows independent content management and real-time changes, reducing bottlenecks. For example, Anastasija S., Product Content Coordinator, highlighted the instant visibility of changes on the front-end. (Source)

How quickly can I implement Hygraph for asset management in my project?

Implementation time varies by project complexity. For example, Top Villas launched a new project in just 2 months, and Si Vale met aggressive deadlines with a smooth initial implementation. Hygraph's onboarding process, free API Playground, and extensive documentation help teams get started quickly. (Source)

What are some real-world success stories of companies using Hygraph for asset management?

Notable customers include Samsung (scalable API-first application), Dr. Oetker (MACH architecture), Komax (3x faster time to market), AutoWeb (20% increase in monetization), and Voi (multilingual content across 12 countries). See case studies for details.

What industries are represented among Hygraph's asset management customers?

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, government, consumer electronics, engineering, and construction. (Source)

How does Hygraph compare to other CMS platforms for asset management?

Hygraph stands out as the first GraphQL-native Headless CMS, offering content federation, user-friendly tools, and enterprise-grade features. It simplifies schema evolution, integrates multiple data sources, and provides robust security and performance. Hygraph ranked 2nd out of 102 Headless CMSs in the G2 Summer 2025 report and was voted easiest to implement four times. (Source)

What pain points does Hygraph solve for asset management and uploads?

Hygraph addresses developer dependency, legacy tech stack modernization, content inconsistency, workflow challenges, high operational costs, slow speed-to-market, scalability issues, complex schema evolution, integration difficulties, performance bottlenecks, and localization/asset management for global teams. (Source)

How does Hygraph differentiate itself in solving asset management challenges?

Hygraph differentiates itself with a user-friendly interface, GraphQL-native architecture, content federation, cost efficiency, accelerated speed-to-market, robust APIs, Smart Edge Cache, and advanced localization/asset management. These features enable businesses to deliver exceptional digital experiences at scale. (Source)

Introducing Click to Edit

Working with React Dropzone and Hygraph Uploads

Upload files to Hygraph, and store them as assets using React Dropzone.
Jamie Barton

Written by Jamie 

Dec 22, 2021
React Dropzone + Hygraph

Quite often you'll want to store user submitted content with Hygraph, and we've made this very easy for anything that's related to content, but what about file uploads? Every Hygraph project has an API endpoint for uploading files directly, or by remote URL that will be stored as Assets within your Hygraph project.

Simply append /upload to your project API endpoint, and upload by file, or remote URL:

https://[region].hygraph.com/v2/[projectId]/[environment]/upload

It's also best to create a dedicated Permanent Auth Token for uploads.

⚠️ Using this endpoint with a Permanent Auth Token will expose that to anyone uploading files, so we’ll need to create a proxy to pass on the file to Hygraph.

If you want to upload files from one service to another, in a safe environment (server context, e.g. server endpoint) then you can use form-data (FormData API) package to do this easily:

const form = new FormData();
form.append('fileUpload', fs.createReadStream('path/to/file.png'));
fetch(`${process.env.HYGRAPH_URL}/upload`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.HYGRAPH_ASSET_TOKEN}`,
},
body: form,
});

Alternatively, you can use fetch to upload via a remote URL of an asset hosted elsewhere:

const fetch = require('node-fetch');
fetch(`${process.env.HYGRAPH_URL}/upload`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.HYGRAPH_ASSET_TOKEN}`,
'Content-Type': 'application/x-www-form-urlencoded',
},
body: `url=${encodeURIComponent(
'https://eu-central-1-shared-euc1-02.graphassets.com/AvHQ3RDvFSousA8iwElOKz/P3TkBzxyQLupgDWNFydB'
)}`,
});

#Client side file uploads

While these work for assets you control, or an asset already hosted in the previous example, what if you wanted to allow your user to upload a file by drag 'n' drop?

React Dropzone is a popular library that will help us with this.

I'll assume you have a React frontend setup, Create React App makes it really easy if you haven't already got something going.

Let's take a look at the "Quickstart" provided by the React Dropzone docs to get going:

import React, { useCallback } from 'react'
import { useDropzone } from 'react-dropzone'
function MyDropzone() {
const onDrop = useCallback(acceptedFiles => {
// Do something with the files
}, [])
const {getRootProps, getInputProps, isDragActive} = useDropzone({onDrop})
return (
<div {...getRootProps()}>
<input {...getInputProps()} />
{
isDragActive ?
<p>Drop the files here ...</p> :
<p>Drag 'n' drop some files here, or click to select files</p>
}
</div>
)
}

We can take this code and adjust it to work with Hygraph in a few lines.

Inside of the onDrop function, let's invoke FormData, and fetch to make this happen.

const onDrop = useCallback(
(acceptedFiles) => {
setFiles(
acceptedFiles.map((file) =>
Object.assign(file, {
preview: URL.createObjectURL(file)
})
)
);
const form = new FormData();
form.append("fileUpload", acceptedFiles[0]);
fetch(
"/api/upload",
{
method: "POST",
body: form
}
);
},
[setFiles]
);

You can also restrict the type of accepted files by specifying accept to the useDropzone hook. For example, to accept images, use:

const { getRootProps, getInputProps, isDragActive } = useDropzone({
accept: "image/*",
onDrop
});

You'll notice above we're using setFiles, which is state we'll store with React.useState. Update your React imports to include useState, and useEffect:

import React, { useCallback, useState, useEffect } from "react";

Then inside of your MyDropzone component, add:

const [files, setFiles] = useState([]);

Next you'll want to invoke useEffect inside of your MyDropzone component:

useEffect(
() => () => {
files.forEach((file) => URL.revokeObjectURL(file.preview));
},
[files]
);

Then wherever you want to show a preview of your files, you can do so using the files from useState:

{files.map((file, index) => (
<div key={file.name}>
<img
src={file.preview}
style={{ width: "100px", height: "100px" }}
alt=""
/>
</div>
))}

We're sending the file to /api/upload which we'll need to create next.

Here we're using express, form-data, node-fetch, and multer to handle the uploads. You can use whatever framework/language you want to create this proxy, but here's a quickstart example:

const express = require('express');
const FormData = require('form-data');
const fetch = require('node-fetch');
const multer = require('multer')();
const app = express();
app.post('/upload', multer.single('fileUpload'), (req, res, next) => {
const fileUpload = req.file;
if (!fileUpload) {
const error = new Error('No file attached');
error.status = 400;
return next(error);
}
const form = new FormData();
form.append('fileUpload', fileUpload.buffer, fileUpload.originalname);
fetch(`${process.env.HYGRAPH_ENDPOINT}/upload`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.HYGRAPH_TOKEN}`,
},
body: form,
})
.then((response) => response.json())
.then((data) => res.send(data))
.catch((err) => res.send({ message: 'Something went wrong' }));
});
app.listen(4000, () => {
console.log('Running on port 4000');
});

You'll notice here we're passing the fileUpload onto HYGRAPH_ENDPOINT/upload. You'll want to set the values as an environment variable so the server can read these. If you're working in development, you can use dotenv to read from .env automatically.

Create React App makes proxying requests to a backend API easy with a simple update to package.json.

Inside of package.json add "proxy": "http://localhost:4000". You'll want to update the port 4000 if you made a change inside of the Express server above.

All that's left to do is run your frontend app, and backend server.

You can get the code on GitHub and work with this locally.

Blog Author

Jamie Barton

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.