Skip to content
This repository has been archived by the owner on Oct 29, 2023. It is now read-only.

Latest commit

 

History

History
56 lines (39 loc) · 1.75 KB

README.md

File metadata and controls

56 lines (39 loc) · 1.75 KB

@akane/web

Configuration

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.

Development

pnpm dev

Production

pnpm build
pnpm start

Hooks

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