https://github.com/raviqqe/onerpc
The router-less serverless RPC framework for TypeScript
https://github.com/raviqqe/onerpc
aws-lambda edge-computing nextjs rpc typescript
Last synced: about 1 month ago
JSON representation
The router-less serverless RPC framework for TypeScript
- Host: GitHub
- URL: https://github.com/raviqqe/onerpc
- Owner: raviqqe
- License: mit
- Created: 2023-05-22T03:01:29.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-10T05:45:40.000Z (about 1 month ago)
- Last Synced: 2025-04-10T06:37:11.540Z (about 1 month ago)
- Topics: aws-lambda, edge-computing, nextjs, rpc, typescript
- Language: TypeScript
- Homepage: https://raviqqe.github.io/oneRPC
- Size: 2.14 MB
- Stars: 28
- Watchers: 3
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# oneRPC
[](https://github.com/raviqqe/onerpc/actions)
[](https://codecov.io/gh/raviqqe/onerpc)
[](https://www.npmjs.com/package/onerpc)
[](LICENSE)The router-less serverless RPC framework.
oneRPC is a minimal RPC library to convert a server-side function of a type, `(input: T) => Promise` into `(request: Request) => Promise` and make it callable from the client side in a type-safe way.
Currently, we support [Next.js Route Handlers][route-handlers] and [AWS Lambda](https://aws.amazon.com/lambda/).
## Features
- 🔮 Seamless client-server communication
You can call remote procedures just as seamless as calling local functions.
- 🛡️ Type safe
Server-client communication is made safe with request and response types in TypeScript which are used by both client and server.
- 🔥 Serverless first
Routing is delegated to other frameworks or infrastructures.
- 🤝 HTTP friendly
You can leverage full potential of HTTP functionalities, such as cache control headers.
- 🐁 Minimal dependencies
It depends only on [Web APIs](https://developer.mozilla.org/en-US/docs/Web/API). Thus, it works on many platforms including Node.js, Deno, and edge runtimes.
- 🌊 Streaming support
Stream responses are transferred as [JSON Lines](https://jsonlines.org/) and clients can consume them chunk by chunk.
## Documentation
[Here](https://raviqqe.com/oneRPC).
## Examples
For all examples, see a [`examples`](examples) directory.
### Next.js with [Route Handlers][route-handlers]
`app/api/foo/route.ts`:
```typescript
import { query } from "onerpc";
import { z } from "zod";export const GET = query(z.number(), z.string(), (x) => `Hello, ${x}!`, {
path: "/api/foo",
});
````app/page.tsx`:
```typescript
import { type GET } from "@/app/api/foo/route";
import { query } from "onerpc/client";export default async (): Promise => (
{await query("/api/foo", 42))}
);
```## References
- [tRPC](https://trpc.io/)
- [Hono.js](https://hono.dev/)
- [Route Handlers | Next.js](https://nextjs.org/docs/app/building-your-application/routing/router-handlers)## License
[MIT](LICENSE)
[route-handlers]: https://nextjs.org/docs/app/building-your-application/routing/router-handlers