Clone the .env.example
file and rename it to .env
. Then, fill in the required fields:
cp .env.example .env
Environment Variables
Environment Variable | Required |
---|---|
NEXTAUTH_URL |
Yes |
NEXTAUTH_SECRET |
Yes |
DISCORD_CLIENT_ID |
Yes |
DISCORD_CLIENT_SECRET |
Yes |
NEXT_PUBLIC_DISCORD_API_BASE_URL |
Yes |
Note You can get your Discord application's client ID and secret from the Discord Developer Portal.
pnpm dev
pnpm build
pnpm start
This hook is used to fetch data from the Discord API. It is a wrapper around useSWR
that automatically adds the Authorization
header to the request and type-safety for the options and response.
import { useSWRDiscordApi } from "src/hooks/useSWRDiscordApi";
import type { GetGuildsResponse } from "discord-api-types/v9";
const [data, error, isLoading] =
useSWRDiscordApi<GetGuildsResponse>("/users/@me/guilds");
// data: GetGuildsResponse | undefined
// error: Error | undefined
// isLoading: boolean