Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

envOnly.ts

9 lines416 Bytes

1type EnvOnlyFn = <TFn extends (...args: Array<any>) => any>(fn: TFn) => TFn
2​
3// A function that will only be available in the server build
4// If called on the client, it will throw an error
5export const createServerOnlyFn: EnvOnlyFn = (fn) => fn
6​
7// A function that will only be available in the client build
8// If called on the server, it will throw an error
9export const createClientOnlyFn: EnvOnlyFn = (fn) => fn