Skip to main content

React Subscriptions

useSubscription#

Hook designed to be used for GraphQL Subscriptions.

For more configuration of Subscriptions check here.

Features:#

  • Subscribe on-demand
  • Automatic unsubscribe on component unmount
  • Automatic updates on cache changes

Example#

import { useSubscription } from '../gqless';
export function Example() {
const { newNotification } = useSubscription();
if (newNotification) {
return (
<p>
New Notification: <b>{newNotification}</b>
</p>
);
}
return <p>Waiting for new notifications...</p>;
}
Last updated on by github-actions[bot]