GraphQL APIのクライアントを含むパッケージです。
import { createClient } from '@hackersheet/core';
import { cache } from 'react';
const client = cache(() =>
createClient({
url: process.env.HACKER_SHEET_API_ENDPOINT!,
accessKey: process.env.HACKER_SHEET_API_ACCESS_KEY!,
})
)();
export { client };
import Link from 'next/link';
import { client } from '@/lib/hackersheet/client';
export default async function Home() {
const { documents } = await client.getDocuments();
return (
<main>
<ul>
{documents &&
documents.map((document) => (
<li key={document.id}>
<Link href={`/posts/${document.slug}`}>{document.title}</Link>
</li>
))}
</ul>
</main>
);
}