Skip to content

feat: suspense-compatible direct API usage#1

Merged
jbojcic1 merged 7 commits intomasterfrom
suspense-compatible-alternative
Feb 28, 2026
Merged

feat: suspense-compatible direct API usage#1
jbojcic1 merged 7 commits intomasterfrom
suspense-compatible-alternative

Conversation

@gudnuf
Copy link

@gudnuf gudnuf commented Feb 26, 2026

Summary

  • Adds a configure() function and exports all API functions directly from the package, enabling usage without the React context provider
  • This makes the SDK compatible with React Suspense and data-fetching libraries like TanStack Query
  • The existing OpenSecretProvider / useOpenSecret pattern still works but is marked as deprecated

Changes

  • New src/lib/config.ts: Global configuration singleton (configure, getConfig, isConfigured, resetConfig)
  • src/lib/api.ts: Removed client_id parameter from 10 auth functions — they now read it internally from the global config via getConfig()
  • src/lib/index.ts: Exports all API functions directly with friendly aliases (signIn, signUp, get, put, del, etc.), plus config, attestation, and AI helper exports
  • src/lib/main.tsx: OpenSecretProvider now delegates to configure() internally; removed clientId from all internal API calls
  • src/lib/context.ts: Added @deprecated JSDoc to useOpenSecret()
  • Test files: All integration tests updated to use centralized test/setup.ts for SDK configuration

Usage

import { configure, signIn, get, put, fetchUser } from "@opensecret/react";

// Configure once at app initialization
configure({ apiUrl: "https://...", clientId: "your-uuid" });

// Use functions directly — works with Suspense, TanStack Query, etc.
await signIn(email, password);
const user = await fetchUser();
const value = await get("key");

Test plan

  • TypeScript compiles cleanly (tsc --noEmit and tsc -p tsconfig.build.json)
  • Integration tests pass against a live backend
  • Verify existing provider-based usage still works (backward compatible)

Based on jbojcic1/OpenSecret-SDK#1, adapted for the latest SDK version.

🤖 Generated with Claude Code

@gudnuf gudnuf mentioned this pull request Feb 26, 2026
3 tasks
jbojcic1 and others added 5 commits February 27, 2026 13:38
…URL state

config.ts is now the single source of truth. api.ts and apiConfig.ts pull
from getConfig() lazily instead of having configure() push values into them
via async dynamic imports. This fixes timing issues and removes circular
dependency workarounds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gudnuf gudnuf force-pushed the suspense-compatible-alternative branch from 28f130c to 564c895 Compare February 27, 2026 22:18
@jbojcic1 jbojcic1 merged commit 31afd19 into master Feb 28, 2026
@jbojcic1 jbojcic1 deleted the suspense-compatible-alternative branch February 28, 2026 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants