Skip to content

[landing-page][Setup] API client, TanStack Query, and environment config #318

Description

@Benjtalkshow

Context

Boundless Builders (builders.boundlessfi.xyz) is a read-only showcase. It reads ecosystem data (builders, projects, teams) from the shared boundless-nestjs backend and never writes. Every landing-page section depends on a fetch client and a server-state layer, so this issue sets that up first.

This issue blocks all other landing-page issues. Do it first.

What to build

  1. Environment variable. The current .env.example holds a bare URL. Replace it with a named var:

    # boundless-nestjs backend origin. All routes are served under /api.
    NEXT_PUBLIC_API_URL="https://stage-api.boundlessfi.xyz"
    
  2. Typed fetch clientlib/api/client.ts exporting apiFetch<T>(path, init?) that:

    • Prefixes requests with ${NEXT_PUBLIC_API_URL}/api (so you call apiFetch('/leaderboard')).
    • Sends no auth (all reads are public/anonymous).
    • Unwraps the response envelope. List endpoints return { data, pagination: { page, limit, total, totalPages, hasNext, hasPrev } } (see ENDPOINTS.md). Confirm the exact envelope against a live response before finalizing.
    • Throws a typed error on non-2xx.
  3. State management (TanStack Query) — add @tanstack/react-query, create providers/query-provider.tsx, and wire it into providers/index.tsx (this file already exists and holds the theme provider). Set sane defaults: a reasonable staleTime, refetchOnWindowFocus: false, and no retry on 4xx.

  4. Shared typeslib/api/types.ts with a Paginated<T> type matching the pagination shape above.

Where files go

  • lib/api/client.ts, lib/api/types.ts (new lib/api/ folder, mirroring the existing lib/utils.ts / lib/initials.ts).
  • providers/query-provider.tsx, wired into the existing providers/index.tsx.
  • .env.example (edit in place).

How Boundless builds this (reference)

The main boundless-platform repo is private, so here is the pattern to mirror: it uses a single typed client under lib/api/ plus TanStack Query, with thin per-feature query hooks that call the client and return data. We copy that pattern minus the auth and OpenAPI-codegen layers, since this app only does public reads. Our providers/index.tsx already follows their provider-tree pattern (the theme provider is in place); add the query provider alongside it.

Design system

No UI in this issue. Follow the code style in CONTRIBUTING.md (single quotes, no em dashes).

Out of scope

No auth, no write methods, no OpenAPI codegen, no React Query hooks for specific screens yet (those come with each section).

Acceptance criteria

  • .env.example defines NEXT_PUBLIC_API_URL with the staging base URL.
  • apiFetch compiles, is typed, and unwraps the envelope.
  • QueryProvider wraps the app through providers/index.tsx.
  • A throwaway useQuery calling GET /api/leaderboard returns data locally (remove before merge).
  • npm run lint and npm run build pass.

References (in this repo)

  • ENDPOINTS.md — the full read-only API surface and the envelope shape.
  • providers/index.tsx, providers/theme-provider.tsx — the provider-tree pattern to extend.
  • lib/utils.ts — existing helper style to match.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions