A modular and reusable SDK for the Bid-Scents Marketplace, built with TypeScript, Zustand, and Zod. This SDK provides stores, API clients, and utilities shared across web and mobile apps. React Query is used in the consuming applications for data fetching.
git clone https://github.com/BidScents/shared-sdk.git
cd shared-sdk
bun install # or npm installbun run buildbun run generate-apishared-sdk/
├── src/
│ ├── api/ # OpenAPI-generated client
│ ├── config/ # Configuration
│ ├── stores/ # Zustand stores (auth, listings, etc.)
│ ├── utils/ # Utility modules
│ ├── types/ # Shared types
│ └── index.ts # Main SDK export
├── dist/ # Compiled output (auto-generated)
├── tests/ # Future tests
├── .gitignore
├── package.json
├── tsconfig.json
└── README.md
"scripts": {
"build": "tsc",
"dev": "tsc --watch",
"clean": "rm -rf dist",
"generate-api": "openapi-typescript-codegen --input http://localhost:3000/api-docs --output src/api",
"prepublishOnly": "bun run clean && bun run build",
"test": "echo \"No tests yet\" && exit 0"
}| Category | Packages |
|---|---|
| Core | zustand, zod |
| Peer | react >= 18.0.0 |
| Dev | typescript, @types/react, @types/node, openapi-typescript-codegen |
- Zustand manages client-side state (auth, listings, etc.)
- Zod handles runtime schema validation
- OpenAPI codegen auto-generates
src/apiclient functions from your backend - React Query is used in consuming apps to handle remote data fetching
- All modules are re-exported from
src/index.tsfor clean usage
The SDK provides the building blocks, while apps handle data fetching:
// In your web/mobile app
import { apiClient, authStore } from '@bid-scents/shared-sdk'
import { useQuery } from '@tanstack/react-query'
// App-specific React Query hooks
const useListings = () => {
return useQuery({
queryKey: ['listings'],
queryFn: () => apiClient.getListings(),
// App-specific configuration
})
}
// Use SDK stores directly
const { user, login } = authStore()For scoped publishing to npm:
bun login
bun publish --access publicMake sure package.json has "name": "@bid-scents/shared-sdk" and correct main/types/files.
Use this SDK to abstract business logic and API clients from your web and mobile apps. Keep stores small and focused, validate all inputs with Zod, and auto-generate API clients whenever your backend changes.
Apps should implement their own React Query hooks using the SDK's API client functions, allowing for app-specific caching strategies and data fetching patterns.