Type-safe API development and code share tool
Easily share code between TypeScript projects, ensuring type consistency, avoiding potential errors, and enhancing the development experience.
🚀 First principle
From the essence of the re-organization of the code, no longer manually write the API call code as well as add types; easy to understand the concepts, and provide a different development experience.
🐱 Simple but familiar
If you know how to develop APIs using Express.js, then you will already know how to using tsdk to develop end-to-end type-safe APIs.
💫 Powerful and flexible
Depending on the core data of the API, we can: generate and export SWR or React Query hooks; exporting the SDK for the core business logic; API permission import; API auth permission detection ......
Frequently Asked Questions
What is a type-safe API?
In traditional development, the backend engineer writes the API and writes the relevant documents. Then, the frontend developer writes the request API function based on the documentation.
However, in type-safe API development, once the backend API is finished, the frontend merely needs to install the API module and import the API function, eliminating the need for any manual wrap code.
Is tsdk production ready?
Yes! tsdk has worked on the API for several years resulting in a streamlined process. If you have experience using Express.js in production, you will have no difficulties using tsdk in production.
What's the difference between tRPC and tsdk?
Both tRPC and tsdk can do type-safe API development, but they are implemented differently and offer different other features.
In short, tRPC is great, while tsdk provides another option.
In short, tRPC is great, while tsdk provides another option.
Next.js Server Actions are already type-safe, do we need tsdk?
If your front-end and back-end code can be written inside Next.js, you don't need to use tsdk; when you need to separate front-end and back-end services, you can use tsdk.
Take a Look
Directly call the API function:
SimpleTest.ts
import {
GetHello
} from 'fe-sdk';
GetHello({world: 'tsdk'}).then(res => {
console.log(res.result);
})
Use the config as API:
Hello.api.ts
import {
GetHelloConfig, GetHelloReq, GetHelloRes
} from './Hello.apiconf';
import { genRoute, type RequestInfo } from './gen-route';
export function setupHelloAPI() {
genRoute<GetHelloReq, GetHelloRes>(
GetHelloConfig,
async (data, reqInfo: Readonly<RequestInfo>) => {
return { result: `Hello ${data.world}` };
}
);
}
Let's make it thing
Join Discussions