Skip to main content

ClientNetWire

This item only works when running on the client. Client

Client-side NetWire implementation using Sleitnick's Comm under the hood. Provides a clean interface for consuming server-exposed networking APIs.

Structure:

  • ClientNetWireClass: Contains static methods (utilities, promises, etc.)
  • ClientNetWire: Contains instance methods and constructor

This separation ensures better linting support and prevents static methods from appearing in instance method suggestions.

Key Features:

  • Promise-based readiness: Wait for server APIs to become available
  • Automatic proxy creation: Seamless access to server methods and events
  • Type safety: Full typing support with proper metatable integration
  • Middleware support: Promise conversion and other transformations
CAUTION

Wire indices may not always be ready for use immediately after creating a ClientNetWire. This can be the case if the ServerWire is created dynamically. To wait for a ClientNetWire to be ready for use, use NetWire.promiseWire. And then to wait for a particular index to be ready, use NetWire.promiseIndex.

local NetWire = require(game:GetService("ReplicatedStorage").NetWire)

local myNetWire = NetWire.Client("MyNetWire")

myNetWire:ServerSideFunction(someArg)

myNetWire.ServerSideEvent:Connect(function(someArg)
    print(someArg)
end)

myNetWire.ServerSideEvent:Fire(someArg)

Types

ClientMiddleware

type ClientMiddleware = (args{any}) → (
shouldContinueboolean,
...any
)

Middleware function for client-side operations. Returns whether to continue processing and any modified arguments.

Functions

new

ClientNetWire.new(nameSpacestring) → ClientNetWire

Creates a new ClientNetWire. If a ClientNetWire with the same nameSpace already exists, it will be returned instead.

onReady

ClientNetWire.onReady(clientNetWirestring | ClientNetWire) → Promise<ClientNetWire>

Returns a promise that resolves when the ClientNetWire is ready for use.

isReady

ClientNetWire.isReady(clientNetWireClientNetWire | string) → boolean

Can be used to check if a clientNetWire is ready for use. Accepts either a ClientNetWire instance or a string name of the wire. Returns true if the ClientNetWire is ready, false otherwise.

indexReady

ClientNetWire.indexReady(
wireOrNameClientNetWire | string,
idxstring--

The index to wait for existence of

) → Promise<...any>

Returns a promise that resolves when the ClientNetWire is ready for use and the index exists. The resolved value is the value of the index.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Creates a new ClientNetWire. If a ClientNetWire with the same nameSpace already exists, it will be returned instead.",
            "params": [
                {
                    "name": "nameSpace",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "ClientNetWire"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 165,
                "path": "lib/netwire/src/ClientWire.luau"
            }
        },
        {
            "name": "onReady",
            "desc": "Returns a promise that resolves when the ClientNetWire is ready for use.",
            "params": [
                {
                    "name": "clientNetWire",
                    "desc": "",
                    "lua_type": "string | ClientNetWire"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<ClientNetWire>\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 274,
                "path": "lib/netwire/src/ClientWire.luau"
            }
        },
        {
            "name": "isReady",
            "desc": "Can be used to check if a clientNetWire is ready for use.\nAccepts either a ClientNetWire instance or a string name of the wire.\nReturns `true` if the ClientNetWire is ready, `false` otherwise.",
            "params": [
                {
                    "name": "clientNetWire",
                    "desc": "",
                    "lua_type": "ClientNetWire | string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 303,
                "path": "lib/netwire/src/ClientWire.luau"
            }
        },
        {
            "name": "indexReady",
            "desc": "Returns a promise that resolves when the ClientNetWire is ready for use and the index exists.\nThe resolved value is the value of the index.",
            "params": [
                {
                    "name": "wireOrName",
                    "desc": "",
                    "lua_type": "ClientNetWire | string"
                },
                {
                    "name": "idx",
                    "desc": "The index to wait for existence of",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<...any>\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 323,
                "path": "lib/netwire/src/ClientWire.luau"
            }
        },
        {
            "name": "destroy",
            "desc": "Destroys a ClientNetWire, removing it from the cache.",
            "params": [
                {
                    "name": "clientNetWire",
                    "desc": "",
                    "lua_type": "ClientNetWire"
                }
            ],
            "returns": [],
            "function_type": "static",
            "private": true,
            "source": {
                "line": 344,
                "path": "lib/netwire/src/ClientWire.luau"
            }
        }
    ],
    "properties": [
        {
            "name": "ClassName",
            "desc": "",
            "lua_type": "\"ClientNetWire\"",
            "private": true,
            "readonly": true,
            "source": {
                "line": 132,
                "path": "lib/netwire/src/ClientWire.luau"
            }
        },
        {
            "name": "Client",
            "desc": "",
            "lua_type": "ClientNetWire",
            "realm": [
                "Client"
            ],
            "private": true,
            "source": {
                "line": 378,
                "path": "lib/netwire/src/ClientWire.luau"
            }
        }
    ],
    "types": [
        {
            "name": "ClientMiddleware",
            "desc": "Middleware function for client-side operations.\nReturns whether to continue processing and any modified arguments.",
            "lua_type": "(args: {any}) -> (shouldContinue: boolean, ...any)",
            "source": {
                "line": 73,
                "path": "lib/netwire/src/NetWireTypes.luau"
            }
        }
    ],
    "name": "ClientNetWire",
    "desc": "Client-side NetWire implementation using Sleitnick's Comm under the hood.\nProvides a clean interface for consuming server-exposed networking APIs.\n\n**Structure:**\n- `ClientNetWireClass`: Contains static methods (utilities, promises, etc.)\n- `ClientNetWire`: Contains instance methods and constructor\n\nThis separation ensures better linting support and prevents static methods from appearing \nin instance method suggestions.\n\n**Key Features:**\n- **Promise-based readiness**: Wait for server APIs to become available\n- **Automatic proxy creation**: Seamless access to server methods and events\n- **Type safety**: Full typing support with proper metatable integration\n- **Middleware support**: Promise conversion and other transformations\n\n:::caution\nWire indices may not always be ready for use immediately after creating a ClientNetWire.\nThis can be the case if the ServerWire is created dynamically. To wait for a ClientNetWire\nto be ready for use, use NetWire.promiseWire. And then to wait for a\nparticular index to be ready, use NetWire.promiseIndex.\n:::\n\n```lua\nlocal NetWire = require(game:GetService(\"ReplicatedStorage\").NetWire)\n\nlocal myNetWire = NetWire.Client(\"MyNetWire\")\n\nmyNetWire:ServerSideFunction(someArg)\n\nmyNetWire.ServerSideEvent:Connect(function(someArg)\n    print(someArg)\nend)\n\nmyNetWire.ServerSideEvent:Fire(someArg)\n```",
    "realm": [
        "Client"
    ],
    "source": {
        "line": 45,
        "path": "lib/netwire/src/ClientWire.luau"
    }
}