https://github.com/thednp/vite-uni-rpc
⚡ A Vite plugin for creating server functions with automatic Remote Procedure Calls (RPC) generation
https://github.com/thednp/vite-uni-rpc
express fastify fastify-plugin hono rpc-library vite
Last synced: 2 months ago
JSON representation
⚡ A Vite plugin for creating server functions with automatic Remote Procedure Calls (RPC) generation
- Host: GitHub
- URL: https://github.com/thednp/vite-uni-rpc
- Owner: thednp
- License: mit
- Created: 2024-12-28T20:12:18.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-16T17:43:51.000Z (about 1 year ago)
- Last Synced: 2025-05-16T18:39:26.743Z (about 1 year ago)
- Topics: express, fastify, fastify-plugin, hono, rpc-library, vite
- Language: TypeScript
- Homepage:
- Size: 612 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## vite-uni-rpc
A Vite plugin for creating server functions with automatic Remote Procedure Calls generation.
### Features
- File-level server code isolation without using directives like `'use server'`
- System wide configuration via vite like config file
- Automatic RPC generation for server functions
- Server-side caching with single-flight requests
- Flexible middleware system with hooks support and adapters for `express`, `fastify` and `hono`
- Framework agnostic
- TypeScript support
> NOTE - this is a work in progress plugin. Do not use in production apps.
### Examples
| Example | Source Code | Try online |
| ------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| SPA - node:http | [SPA](https://github.com/thednp/vite-uni-rpc/tree/main/examples/spa) | [StackBlitz](https://stackblitz.com/fork/github/thednp/vite-uni-rpc/tree/main/examples/spa) |
| Express | [Express](https://github.com/thednp/vite-uni-rpc/tree/main/examples/express) | [StackBlitz](https://stackblitz.com/fork/github/thednp/vite-uni-rpc/tree/main/examples/express) |
| Fastify | [Fastify](https://github.com/thednp/vite-uni-rpc/tree/main/examples/fastify) | [StackBlitz](https://stackblitz.com/fork/github/thednp/vite-uni-rpc/tree/main/examples/fastify) |
| Hono | [Hono](https://github.com/thednp/vite-uni-rpc/tree/main/examples/hono) | [StackBlitz](https://stackblitz.com/fork/github/thednp/vite-uni-rpc/tree/main/examples/hono) |
### Installation
```bash
npm install vite-uni-rpc@latest
```
```bash
pnpm add vite-uni-rpc@latest
```
### Wiki
Please refer to the [Wiki](https://github.com/thednp/vite-uni-rpc/wiki) for guides on installation, configuration and usage.
### TO DO
- [ ] Add/update examples examples
- [ ] Add AbortController
- [ ] Fix `The plugin "vite:dep-scan" was triggered by this import server/server.mjs:1:29: 1 │ import { createServer } from "vite";`
- [x] Add SPA support
- [x] Add wiki
- [x] Test bun
- [x] Add `contentType` option to `createServerFunction`, currently supporting: `application/json`, `text/plain`;
- [ ] Add koa adapter
- [ ] Add Github tooling/workflows
- [ ] Add tests
### To know
* in dev mode **only** vite dev server and express/connect middleware are available
### Credits
This project is inspired by [vite-dev-rpc](https://github.com/antfu/vite-dev-rpc).
### License
Released under [MIT](LICENSE).