Skip to content

Latest commit

 

History

History
57 lines (48 loc) · 1.16 KB

File metadata and controls

57 lines (48 loc) · 1.16 KB

Note on packaging

Netcode ships two pre-packaged versions of the library — one for Node and one for the browser — so you can use it out of the box. You can also import the ES module source code directly and manage the packaging yourself with a tool like Vite or webpack.

Let's see an example of both setups:

Using the pre-packaged libraries

On the server side (Node, ES modules):

import {
    Server,
    BinaryEncoder,
    UInt16Codec,
    BooleanCodec,
    StringCodec,
    // ...
} from 'netcode/server';

And in the browser:

<body>
    <!-- Defines a netcode variable in global scope -->
    <script src="netcode.umd.cjs"></script>
    <script>
        const {
            Client,
            BinaryEncoder,
            UInt16Codec,
            BooleanCodec,
            StringCodec,
            // ...
        } = netcode;
    </script>
</body>

Or with ES modules:

<body>
    <script type="module">
        import {
            Client,
            BinaryEncoder,
            UInt16Codec,
            BooleanCodec,
            StringCodec,
            // ...
        } from 'netcode/client';
    </script>
</body>