You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 13, 2026. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+79-6Lines changed: 79 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,21 +3,22 @@
3
3
Framework agnostic transpilation utilities for client/server RPCs, env isolation, islands, module splitting, and more.
4
4
5
5
=======
6
+
6
7
# API
7
8
8
-
## `server$`
9
+
## `serverFn$`
9
10
10
-
The `server$` function is used to create a server-side RPC. It takes a function as its only argument, and returns a function that can be called from the client-side.
11
+
The `serverFn$` function is used to create an isomorphic server-side RPC. It takes a function and an optional configuration object and returns a function that can be called on both server (ssr or ssg) and client. The function passed to `serverFn$` will only be executed on the server. On the client, a `fetch` call is made to the server function instead. The results of the function will be exactly the same on both server and client.
11
12
12
13
**🧠 Important Notes**:
13
14
14
15
- The server-side function must be an `async` function.
15
-
-RPC's default to `POST`requests and pass payloads as request the request body. To use `GET` requests and search-param payloads instead, the `opts.method` can be set to `GET`. This will automatically configure both the method and the payload serialization to work via search params instead of a request body. You can also alter the actual request (and request body) manually to your liking.
16
+
-The fetch calls made by the client default to using the `POST`method and passing arguments via the request body. To use `GET` requests and search-param payloads instead, the `opts.method` can be set to `GET`. This will automatically configure both the method and the payload serialization to work via search params instead of a request body. You can also alter the actual request (and request body) manually to your liking.
@@ -111,4 +112,76 @@ A function that can be called isomorphically from server or client side code to
111
112
- The request object to be passed to the `fetch` call to the server function.
112
113
- Can be used to add headers, signals, etc.
113
114
115
+
## `server$` (Coming Soon)
116
+
117
+
The `server$` function can be used to scope any expression to the server-bundle only. This means that the expression will be removed from the client bundle. This is useful for things like server-side only imports, or server-side only code.
118
+
119
+
```tsx
120
+
import { server$ } from'@tanstack/bling'
121
+
122
+
const serverOnly =server$('It is a secret!')')
123
+
```
124
+
125
+
Server Output:
126
+
127
+
```tsx
128
+
const serverOnly =server$('It is a secret!')')
129
+
```
130
+
131
+
Client Output:
132
+
133
+
```tsx
134
+
const serverOnly =undefined
135
+
```
136
+
137
+
### Signature
138
+
139
+
```tsx
140
+
server$<T>(input: T): T|undefined
141
+
```
142
+
143
+
### Arguments
144
+
145
+
-`input`
146
+
- Any function, expression, or variable.
147
+
148
+
### Returns
149
+
150
+
- The variable on the server
151
+
-`undefined` on the client
152
+
153
+
## `split$` (Coming Soon)
154
+
155
+
The `split$` function can be used to code-split any asynchronous function on both server and client at build-time.
0 commit comments