---
description: Create a server and allow remote connection.
---

# Server

### `new Server(options)`

Create a server to be able to connect remotely.

| Parameter                    | Default | Description                                                                                                                                                                                                                                                                     |
| ---------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| options                      |         | <p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a><br>Server options.</p>                                                                                                                                          |
| options.port                 | `4951`  | <p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a> (optional)<br>Port of server.</p>                                                                                                                               |
| options.users                |         | <p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>><br>List of users to connect to the server.</p> |
| options.users\[].username    |         | <p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">String</a><br>Name of the user to connect to the server.</p>                                                                                                               |
| options.users\[].password    |         | <p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">String</a><br>Password of the user to connect to the server.</p>                                                                                                           |
| options.users\[].permissions |         | <p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a><br>User's permission flags on collections.</p>                                                                                                                  |

> Example:
>
> ```javascript
> const example_server = new <PeakDB>.Server({
>   "port": 4951,
>   "users": [
>     {
>       "username": "fir4tozden",
>       "password": "ZdJuTNqUXpqNrw2H",
>       "permissions": 1 << 0 | 1 << 3 // read and delete
>     },
>     {
>       "username": "nehir",
>       "password": "yPIkXo3l82aMbJZc",
>       "permissions": 1 << 0 | 1 << 1 | 1 << 2 // read, write and update
>     }
>   ]
> });
> ```
