Skip to main content

Preload queries

tip

Hydrogen 2.0 is out now. These archival Hydrogen 1.0 docs are provided only to assist developers during their upgrade process. Please migrate to Hydrogen 2.0 as soon as possible.

This guide provides information on how to configure preloaded queries in your Hydrogen app.

Disable preloaded queries

You can disable preloaded queries in the following ways:

  • Set cache to CacheNone
  • Opting out with preload: false
const {data} = useShopQuery({
query: QUERY,
variables: {
numCollections: 3,
},
cache: CacheNone(), // `CacheNone()` automatically disables preloaded queries
preload: false, // or you can explicitly tell the query not to preload
});

Preload everywhere

Supply the preload property with either a Boolean value or a string. When the value is *, Hydrogen preloads the query for every request.

const data = fetchSync('https://my.api.com/data.json', {
headers: {
accept: 'application/json',
},
// Preloads queries for every request
preload: '*',
}).json();

Log request timing information

Enable the logger.showQueryTiming property in your Hydrogen configuration file.