Dedicated Server Runtime
Featured

Dedicated Server Runtime

Network Storage now supports dedicated servers.

Most games should still use the normal **P2P / listen server** flow. It is simple, reliable, and works well with the endpoint system.

Dedicated servers are for games that need more control, stricter authority, or no player-hosted sessions.

## Setup

1. Install the sboxcool Network Storage library. https://sbox.game/sboxcool/network-storage
2. Create a Network Storage project on sboxcool.com. https://sboxcool.com/tools/network-storage/new
3. Create a scoped secret key for your dedicated server. `Network Storage -> Your Project -> API Keys`
![(sboxcool.com) api key configuration](https://cdn.sboxcool.com/uploads/blog/6ca44052b0616bdaa09a3479.png)
4. Start your server with:
```bash
+network_storage_secret_key sbox_sk_
```
That is it. Your dedicated server can now call Network Storage directly.
![image](https://cdn.sboxcool.com/uploads/blog/819f1725f0690e32d58c5728.png)

5. Read our wiki/documentation: https://sboxcool.com/wiki/network-storage-v3/dedicated-server-runtime

## Hosting options

Network Storage supports:

- **P2P / listen server**: best for most games. Simple, reliable, and powerful with endpoints.
- **Dedicated server**: best when you want full control and stricter server authority.
- **Mixed setup**: safe reads can stay client-to-web, while gameplay, economy, rewards, and progression go through the server.

Dedicated servers give you more control, but also add hosting, scaling, uptime, region, ping, and deployment concerns.

## Dedicated server example

```csharp
// Collection modifications
await NetworkStorage.SaveDocument( "players", steamId, new { xp = 100 } );

await NetworkStorage.UpdateDocument( "players", steamId,
NetworkStorageOperation.Increment( "xp", 25, source: "dedicated-server", reason: "Match reward" )
);

await NetworkStorage.DeleteDocument( "players", steamId );

// Endpoints
var result = await NetworkStorage.CallEndpoint( "settle-match", new
{
winnerSteamId = winnerId,
matchId = matchId
} );
```

The client never needs the secret key. The server owns the trusted call.

## Security

Do not leak secret keys.

Never put an `sbox_sk_` key in client code, shared configs, screenshots, workshop files, or anything players can download.

For normal dedicated server gameplay, secret keys usually only need:

- `read`
- `endpoint`

You usually do **not** need `write`.

Prefer endpoint execution and keep permissions as small as possible.

## Summary

Use P2P for most games.

Use dedicated servers when you need full control, stricter authority, or do not want player-hosted sessions.

Start the dedicated server with:

```bash
+network_storage_secret_key sbox_sk_
```
React to this post