https://telefunc.com/ [telefu]Telefunc [github][discord][twitter] v0.1.25[changelog] [compass] OverviewIntroductionTourRPC vs GraphQL/REST Get startedViteNext.jsNuxtOther GuidesBasicsAbort() & shield()AuthenticationPermissionsError HandlingFile structureForm validationMoreTypeScriptError TrackingFile UploadTelefunc ServerWaterfallsServer-Side Rendering (SSR) [?] APIProtectionshield()Abort()ContextgetContext() provideTelefuncContext()IntegrationcreateTelefuncCaller()config [close] [tele]Telefunc [telefunc] Telefunc Remote Functions. Instead of API. // CreateTodo.telefunc.js // Environment: Node.js server import { shield, Abort, getContext } from 'telefunc' // Telefunc makes functions exported in `*.telefunc.js` // remotely callable from the browser. export { onNewTodo } // `shield()` is auto-generated when using TypeScript shield(onNewTodo, [{ text: shield.type.string }]) async function onNewTodo({ text }) { const { user } = getContext() if (user === null) throw Abort() // With an ORM: const todoItem = new Todo({text, authorId: user.id}) await todoItem.save() // Or with SQL: await execute( "INSERT INTO todo_items VALUES (:text, :authorId)", { text, authorId: user.id } ) } Server // CreateTodo.jsx // Environment: Browser // The `CreateTodo.telefunc.js` file is not loaded: // Telefunc transforms `*.telefunc.js` imports into a // thin HTTP client. import { onNewTodo } from './CreateTodo.telefunc.js' async function onClick(form) { const text = form.input.value // Behind the scenes, Telefunc makes an HTTP request await onNewTodo({ text }) } function CreateTodo() { return (
) } Browser Simple With Telefunc, you get a simple frontend-backend relationship: it's just a set of remote functions. Your frontend can directly use any SQL/ORM query to retrieve & mutate data. [shield] Permissions Telefunc enables programmatically defined permissions. It's both simple and flexible. Telefunc introduces new techniques that enable advanced permissions and increased safety. Any Stack Telefunc supports Next.js, CRA, Nuxt, Vite, vite-plugin-ssr, React Native and other frameworks based on Webpack, Babel, Parcel or Vite. You want to change your stack? Bring Telefunc along. [?] Performance The frontend can directly tap into the full power of the server. You can use highly tailored & optimized SQL/ORM queries for highly performant data retrieval and mutations. [typescript] TypeScript Seamless TypeScript support out-of-the-box. Use your types across the frontend and backend for end-to-end type safety, including runtime validation. Rock-solid The source code of Telefunc has no known bug (bugs are fixed swiftly) and every release is assailed against a heavy suite of automated tests. Have a question? Want a feature? Found a bug? Join our Discord or open a GitHub ticket.