hytopia
Version:
The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.
64 lines (31 loc) • 1.45 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [server](./server.md) > [startServer](./server.startserver.md)
## startServer() function
Boots the server runtime, runs your init callback, and starts accepting connections.
Use for: normal server startup in your entry file. Do NOT use for: restarting an already running server within the same process.
**Signature:**
```typescript
export declare function startServer(init: ((() => void | Promise<void>) | ((world: World) => void | Promise<void>))): void;
```
## Parameters
<table><thead><tr><th>
Parameter
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
init
</td><td>
((() => void \| Promise<void>) \| ((world: [World](./server.world.md)<!-- -->) => void \| Promise<void>))
</td><td>
Game initialization callback. It can be sync or async. If it accepts a world parameter, the default world is created and passed in.
\*\*Requires:\*\* Call once per process before using gameplay systems.
</td></tr>
</tbody></table>
**Returns:**
void
## Remarks
Initialization order: 1) Physics engine (RAPIER) 2) Block texture atlas preload 3) Model preload 4) Your `init` callback (awaited if async) 5) Server starts accepting connections
If `init` declares a `world` parameter, a default world is created and provided.