FictionArchive React Starter
A minimal React + Vite + Apollo Client scaffold ready to connect to the FictionArchive Fusion gateway. Point it at your own endpoint by changing VITE_GRAPHQL_URI.
Getting started
cd fictionarchive-web
npm install
npm run dev
Then open the printed local URL. Update .env (create it if missing) with your endpoint:
VITE_GRAPHQL_URI=https://localhost:5001/graphql
VITE_OIDC_AUTHORITY=https://your-idp
VITE_OIDC_CLIENT_ID=fictionarchive-web
VITE_OIDC_REDIRECT_URI=http://localhost:5173
VITE_OIDC_POST_LOGOUT_REDIRECT_URI=http://localhost:5173
# Optional: token used only by codegen if your gateway requires auth
VITE_CODEGEN_TOKEN=your_api_token
Scripts
npm run dev: start Vite dev server.npm run build: type-check + production build.npm run codegen: generate typed hooks fromsrc/**/*.graphqlintosrc/__generated__/graphql.ts. Run this manually after changing GraphQL operations or when the gateway schema changes.
Project notes
src/apolloClient.tsconfigures the Apollo client withInMemoryCache, readsVITE_GRAPHQL_URI, and attaches anAuthorization: Bearerheader when an OIDC user is present.- GraphQL code generation is configured via
codegen.ts(loads.env/.env.localautomatically); runnpm run codegento emit typed hooks tosrc/__generated__/graphql.ts(ignored by git) or rely on theprebuildhook. - Routing is handled in
src/App.tsxwithreact-router-dom;/renders the novels listing and/novels/:idis stubbed for future detail pages. - Styles live primarily in
src/index.cssalongside the shared UI components.
Codegen tips
- Default schema URL:
CODEGEN_SCHEMA_URL(falls back toVITE_GRAPHQL_URI, thenhttps://localhost:5001/graphql). - Add
VITE_CODEGEN_TOKEN(orCODEGEN_TOKEN) if your gateway requires a bearer token during introspection. - Generated outputs land in
src/__generated__/graphql.ts(committed to git). Runnpm run codegenafter schema/operation changes.