Framework neutral RPC

I'm trying to understand how I would use bling in a normal client side script.

My intuition about it was that I write a function in a module and export it. It imports a typed remote call on the client and the actual implementation on the server.

This approach, however, imports the imlementation on the client-side.
// src/serverfunctions/x.ts
import { server$ } from '@tanstack/bling'

export default server$(async (five: 5) => {
  console.log('serer function ran here with ' + five)
  return 'result' as const
})

<!-- src/pages/index.astro -->
<script>
    import serverFun from '../serverfunctions/x'
    console.log(await serverFun(5))
</script>
Was this page helpful?