Contact

Gridsome page queries vs static queries

When getting started with Gridsome it seems a bit odd why there's <page-query> and <static-query>. What's the point?

An easy way to think about this is that static queries exists only because of technical limitations. This limitation makes them less flexible, unable to use variables. They are static.

In an ideal world we'd be using page queries everywhere and just call them queries, since they're more powerful. Unfortunately this is not a perfect world.

Page queries are used in pages, and templates.

Anywhere outside of the /pages and /templates folders you'll use <static-query> to pull data from gridsome's GraphQL layer. If you're wishing the query could be dynamic, consider using things like props and slots to pass the data down to your component.


I'm not using comments on this site so feel free to tweet me for any questions, praise, or general conversation.