prim-rpc icon indicating copy to clipboard operation
prim-rpc copied to clipboard

Create nuxt module

Open Rednas83 opened this issue 1 year ago • 3 comments

Looks very interesting. Can't wait for the stable release.

Can you also consider writing a nuxt module for easier setup?

Can it work with all RPC servers? I am only planning to use is as a RPC client

Is it type safe or does it require declaration files?

Rednas83 avatar Jul 05 '24 13:07 Rednas83

Thank you! I had tried writing a Nuxt module a while back but had trouble generating types for user-created functions and generally understanding how Nuxt modules work. It looks like Nuxt has released some new tools to help build modules so I might explore this again in the future. In the meantime I have a guide for setting up Prim+RPC in Nuxt (and its server framework).

The Prim+RPC client could work with other RPC servers! The client by itself only formats RPCs and then a chosen method/callback plugin sends them off to a server. The plugins on the website are intended for the Prim+RPC server but you could write a plugin to send/format that RPC for another server (referencing an existing plugin like this one).

In the future, I'm planning to add more hooks to the client so it's easier to send RPC where it's needed (this might become part of the client refactor).

It's also type-safe. The library depends on type-only imports for functions so you can either directly reference the server-side code if the server/client are contained in the same repository or you could generate a declaration file if the client is in another repository (and share that declaration using a registry or copying/pasting into another project).

doseofted avatar Jul 06 '24 13:07 doseofted

Promising approach to provide rpc :)

If a stable release is around the corner, I could assist wrapping things as nuxt module if you're interested, shouldn't be that hard if i'm not mistaken.

aerophobic avatar Aug 01 '25 15:08 aerophobic

Promising approach to provide rpc :)

If a stable release is around the corner, I could assist wrapping things as nuxt module if you're interested, shouldn't be that hard if i'm not mistaken.

Thank you! I hope to release a stable, refactored version of Prim+RPC in the future but I intend to keep most public-facing interfaces the same (or provide a compat layer) that would make creating a Nuxt module easier, even as the library is unstable today.

But I would love to see a Nuxt module for the RPC library. When I looked into creating one, the most difficult part seemed to be exposing the RPC client with the user's provided function types through some composable utility in Nuxt (this is where I got stuck).

doseofted avatar Aug 11 '25 13:08 doseofted