Origin project please refer: Notus NextJS
- Directly using:
import { gql } from "@apollo/client";
import client from "../apollo-client";
import { useEffect } from "react";
useEffect(() => {
(async () => {
const { data } = await client.query({
query: gql`
query Countries {
countries {
code
name
emoji
}
}
`,
});
console.log(data);
})();
}, []);
- By hook
import ClientOnly from "../../components/Apollo/ClientOnly";
import Countries from "../../components/Logics/Countries";
<ClientOnly>
<Countries />
</ClientOnly>