Urql
urql
A highly customizable and versatile GraphQL client for React
Charts
graphql client
state management
cache
graphql
exchanges
react
urql
Charts
javascript
npm
Stars
9.0k
Weekly
980k
Open issues
30
Bundle
~25 kB
Installation
npm install urqlCode example
import { Client, Provider, cacheExchange, fetchExchange, useQuery } from "urql";
const client = new Client({
url: "https://countries.trevorblades.com/",
exchanges: [cacheExchange, fetchExchange],
});
export function Example() {
return (
<Provider value={client}>
<Countries />
</Provider>
);
}
function Countries() {
const [result] = useQuery({ query: "{ countries { code name } }" });
if (result.fetching) return <p>Loading…</p>;
return <pre>{JSON.stringify(result.data, null, 2)}</pre>;
}Pros & cons
Pros
- Actively maintained by urql GraphQL Contributors
- 980k weekly downloads. Battle tested
- First-class TypeScript definitions
- MIT licensed
Considerations
- Adds roughly ~25 kB to your bundle
- Needs client-only rendering in SSR frameworks
- Not supported in React Native
- 30 open issues on GitHub