npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@entityseven/fivem-rpc

v0.1.0

Published

FiveM RPC is an all-in-one package with asynchronous RPC implementation for FiveM servers in JS/TS

Readme

FiveM RPC

is an all-in package with asynchronous RPC implementation for RageMP servers in JS/TS. Extra info

Motivation

The idea was to create an extensible package, with various features to simplify the development process and provide as much comfort as possible. Inspired by usage of altv-xrpc

Installation

  pnpm i @entityseven/fivem-rpc
  yarn add @entityseven/fivem-rpc
  bun add @entityseven/fivem-rpc

It is highly recommended to also install additional package for enhanced typing

  pnpm i @entityseven/fivem-rpc-shared-types -D
  yarn add @entityseven/fivem-rpc-shared-types --dev
  bun add @entityseven/fivem-rpc-shared-types -d

Usage

FiveM RPC is meant to be a singletone per environment. This means you must create only one RPCFactory per your server/client/web. This also enables modifying const rpc to your needs, adding new methods or variables by forcing you to import it from file instead of library reference

// lib/rpc.ts
import { RPCFactory } from '@entityseven/fivem-rpc'
export const rpc = new RPCFactory(/* options */).get()

Docs

Extras

Along with RPCFactory you can also import all the types used internally, types for native client/server events and lists of native client/server events. All of that is documented in JSDoc, so no need to duplicate it here

RPCConfig

type RPCConfig<T extends RPCEnvironment | unknown> = {
    env: T 
    debug?: boolean
}

Failing to set env to provided type will result in RPCErrors.UNKNOWN_ENVIRONMENT debug adds additional console logs to events

Errors

Known errors could be one of following or an error throw by a callback specifically

enum RPCErrors {
    EVENT_NOT_REGISTERED = 'Event not registered',
    INVALID_DATA = 'Invalid data (possibly broken JSON)',
    NO_PLAYER = 'No player (failed to resolve from local index)',
    UNKNOWN_NATIVE = 'Unknown native event (if you are sure this exists - use native handler)',
    UNKNOWN_ENVIRONMENT = 'Unknown environment (must be either "server", "client" or "webview")',
}

Example error

Values wrapped in <> always exist, just not relevant for an example. Keep in mind that some errors are thrown in their destination(To) point: this example will throw on server

Error: No player (failed to resolve from local index)
Event: 'clientServerEvent'
Uuid: <uuid>
From: 'client'
To: 'server'
Player: <non-existent-player>
Type: 'event'
Data: [<data>]

Server (source)

onClient

Listens to client event

rpc.onClient('clientServerEvent', (player, arg1, arg2, ...rest) => {
    // logic
    return someData // this will be forwarded back to caller
})

offClient

Stops listening to client event

rpc.offClient('clientServerEvent')

emitClient

Sends event to specified client

const response = await rpc.emitClient(playerServerId, 'serverClientEvent', someData) 
// response will come from client listener with returned data

emitClientEveryone

Sends event to all clients

rpc.emitClientEveryone('serverClientEvent', someData)

onWebview

Listens to webview event

rpc.onWebview('webviewServerEvent', (player, arg1, arg2, ...rest) => {
    // logic
    return someData // this will be forwarded back to caller
})

offWebview

Stops listening to webview event

rpc.offWebview('webviewServerEvent')

emitWebview

Sends event to specified webview

const response = await rpc.emitWebview(playerServerId, 'serverWebviewEvent', someData)
// response will come from webview listener with returned data

onSelf

Listens to server event

rpc.onSelf('serverEvent', (arg1, arg2, ...rest) => {
    // logic 
    return someData // this will be forwarded back to caller
})

offSelf

Stops listening to server event

rpc.offSelf('serverEvent')

emitSelf

Sends event to server

const response = await rpc.emitSelf('serverEvent', someData)
// response will come from server listener with returned data

onCommand

Registers chat command. Since arguments are untyped you must validate them yourself

rpc.onCommand('serverCommand', (player, args, commandRaw) => {
    // logic
})

onNativeEvent

Listens to native server event (reference)

rpc.onNativeEvent('playerJoining', (source, oldId) => {
    // logic
})

Client (source)

onServer

Listens to server event

rpc.onServer('serverClientEvent', (arg1, arg2, ...rest) => {
    // logic
    return someData // this will be forwarded back to caller
})

offServer

Stops listening to server event

rpc.offServer('serverClientEvent')

emitServer

Sends event to server

const response = await rpc.emitServer('clientServerEvent', someData)
// response will come from webview listener with returned data

onWebview

Listens to webview event

rpc.onWebview('webviewClientEvent', (arg1, arg2, ...rest) => {
    // logic
    return someData // this will be forwarded back to caller
})

offWebview

Stops listening to webview event

rpc.offWebview('webviewClientEvent')

emitWebview

Sends event to specified webview

const response = await rpc.emitWebview('clientWebviewEvent', someData)
// response will come from webview listener with returned data

onSelf

Listens to client event

rpc.onSelf('clientEvent', (arg1, arg2, ...rest) => {
    // logic 
    return someData // this will be forwarded back to caller
})

offSelf

Stops listening to client event

rpc.offSelf('clientEvent')

emitSelf

Sends event to client

const response = await rpc.emitSelf('clientEvent', someData)
// response will come from client listener with returned data

onCommand

Registers chat command. Since arguments are untyped you must validate them yourself

rpc.onCommand('clientCommand', (player, args, commandRaw) => {
    // logic
})

onNativeEvent

Listens to native client event (reference)

rpc.onNativeEvent('entityDamaged', (victim, culprit, weapon, baseDamage) => {
    // logic
})

onNativeNetworkEvent

Listens to native client network event (reference)

rpc.onNativeNetworkEvent('CEventShockingCarCrash', (entities, eventEntity, data) => {
    // logic
})

setWebviewFocus

Sets or removes focus and cursor from own webview

rpc.setWebviewFocus(true /* focus */, true /* show cursor */)

Webview (source)

onClient

Listens to client event

rpc.onClient('clientWebviewEvent', (arg1, arg2, ...rest) => {
    // logic
    return someData // this will be forwarded back to caller
})

offClient

Stops listening to client event

rpc.offClient('clientWebviewEvent')

emitClient

Sends event to own client

const response = await rpc.emitClient('webviewClientEvent', someData) 
// response will come from client listener with returned data

onServer

Listens to server event

rpc.onServer('serverWebviewEvent', (arg1, arg2, ...rest) => {
    // logic
    return someData // this will be forwarded back to caller
})

offServer

Stops listening to server event

rpc.offServer('serverWebviewEvent')

emitServer

Sends event to server

const response = await rpc.emitServer('webviewServerEvent', someData)
// response will come from webview listener with returned data

onSelf

Listens to webview event

rpc.onSelf('webviewEvent', (arg1, arg2, ...rest) => {
    // logic 
    return someData // this will be forwarded back to caller
})

offSelf

Stops listening to webview event

rpc.offSelf('webviewEvent')

emitSelf

Sends event to webview

const response = await rpc.emitSelf('webviewEvent', someData)
// response will come from webview listener with returned data

License

Licensed under Custom Attribution-NoDerivs Software License