> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getpara.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Server Setup

> Install and configure the Para Server SDK across Node.js, Bun, and Deno environments

The Para Server SDK enables secure server-side blockchain operations across different JavaScript runtime environments.
With nearly identical functionality to client-side implementations, the server SDK allows you to perform signing
operations server-side by either importing client-side sessions or using pregenerated wallets. If you're creating new
wallets from your server rather than importing sessions, start with the [REST API](/v3/rest/overview) instead.

## Installation

Install the Para Server SDK in your preferred JavaScript runtime environment:

<CodeGroup>
  ```bash npm theme={null}
  npm install @getpara/server-sdk --save-exact
  ```

  ```bash yarn theme={null}
  yarn add @getpara/server-sdk --exact
  ```

  ```bash pnpm theme={null}
  pnpm add @getpara/server-sdk --save-exact
  ```

  ```bash bun theme={null}
  bun add @getpara/server-sdk --exact
  ```

  ```bash deno theme={null}
  deno install npm:@getpara/server-sdk
  ```
</CodeGroup>

<Info>
  **Why `--save-exact`?** The Para Server SDK may publish breaking changes in minor versions during active development.
  Pinning the exact version prevents unexpected breakage when you install or update dependencies.
</Info>

## Initialization

Initialize the Para Server SDK with your API key. The initialization process varies slightly depending on your runtime
environment:

<CodeGroup>
  ```typescript Node.js theme={null}
  import { Para as ParaServer } from "@getpara/server-sdk";

  // Standard initialization for Node.js
  const paraServer = new ParaServer("YOUR_API_KEY");

  ```

  ```typescript Bun theme={null}
  import { Para as ParaServer } from "@getpara/server-sdk";

  // Bun requires disabling WebSockets
  const paraServer = new ParaServer("YOUR_API_KEY", {
    disableWebSockets: true
  });
  ```

  ```typescript Deno theme={null}
  import { Para as ParaServer } from "@getpara/server-sdk";

  // Deno requires disabling WebSockets
  const paraServer = new ParaServer("YOUR_API_KEY", {
    disableWebSockets: true,
  });
  ```
</CodeGroup>

### Runtime Compatibility

The Server SDK works across multiple JavaScript runtimes. Some runtimes require additional constructor options:

| Runtime            | `disableWebSockets` | Notes                                                                            |
| ------------------ | :-----------------: | -------------------------------------------------------------------------------- |
| Node.js            |      Not needed     | Full support out of the box                                                      |
| Bun                |     **Required**    | Bun's WebSocket implementation is incompatible with the SDK's internal transport |
| Deno               |     **Required**    | Same as Bun — the SDK falls back to HTTP polling                                 |
| Cloudflare Workers |     **Required**    | Workers runtime doesn't support persistent WebSocket connections                 |

<Warning>
  If you omit `disableWebSockets: true` in Bun, Deno, or Cloudflare Workers, the SDK may fail silently or hang
  during signing operations. Always set this option for non-Node.js runtimes.
</Warning>

<Tip>
  **Signing performance tip:** Para's signing infrastructure runs in `us-east-1`. For the lowest latency on server-side signing operations, deploy your application servers in or near that region.
</Tip>

<Note>If you're using a legacy API key (one without an environment prefix) you must provide the `Environment` as the first argument to the `ParaServer` constructor. You can retrieve your updated API key from the Para Developer Portal at [https://developer.getpara.com/](https://developer.getpara.com/)</Note>

<Tip>
  **Pre-warm the MPC signer:** The first signing operation loads the MPC WASM module and spawns a worker thread, which
  adds latency. Call `initializeWorker()` after setup to pre-warm the signer so subsequent signing calls are fast:

  ```typescript theme={null}
  const paraServer = new ParaServer("YOUR_API_KEY");
  await paraServer.initializeWorker();
  ```
</Tip>

## Authentication Methods

After initializing the Para Server SDK, you need to authenticate it before performing any operations. The server SDK
supports two authentication methods:

### Option 1: Importing Client Sessions

Import an active session from your client application when your backend needs to act for an authenticated user.

In your client application, export the authenticated session and send it to your backend:

```typescript theme={null}
const serializedSession = await para.waitAndExportSession();

await fetch("/api/import-session", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ session: serializedSession }),
});
```

<Info>
  `waitAndExportSession()` waits for the SDK to reach an authenticated state before exporting. Use it for client-to-server handoff flows immediately after login.
</Info>

If the server does not need to sign for the user, export without signer data:

```typescript theme={null}
const sessionWithoutSigners = await para.waitAndExportSession({
  excludeSigners: true,
});
```

<Warning>
  Do not use `{ excludeSigners: true }` when the server needs to sign messages or transactions for the user.
</Warning>

On your server, import the serialized session into a new `ParaServer` instance:

```typescript theme={null}
import { Para as ParaServer } from "@getpara/server-sdk";

app.post("/api/import-session", async (req, res) => {
  const paraServer = new ParaServer("YOUR_API_KEY");
  await paraServer.importSession(req.body.session);

  const isActive = await paraServer.isSessionActive();
  return res.status(200).json({ isActive });
});
```

With a session loaded into the server instance, you can perform the operations that the Para Server SDK supports.

<Warning>
  Create a new `ParaServer` instance for each imported user session. A server SDK instance holds one active session at a time.
</Warning>

<Card horizontal title="Server Session Management" imgUrl="/images/v3/general-server.png" href="/v3/server/guides/sessions" description="Import client sessions, keep them active, and use them for server-side signing." />

### Option 2: Using Pregenerated Wallets

Generate and use deterministic wallets server-side without requiring client-side authentication. This pregen wallet will load the para server instance with a wallet that can be used for all operations that the Para Server SDK supports.

```typescript theme={null}
import { WalletType } from "@getpara/server-sdk";

await paraServer.createPregenWallet({
  type: 'EVM', // or 'SOLANA', 'COSMOS', 'STELLAR'
  pregenId: { email: "user@example.com" },
});
```

<Info>
  When using pregenerated wallets, you'll need to manage the user share of the wallet and store it securely.
</Info>

Learn more about pregen wallets and their usage on the server in our pregen wallets guide.

<Card horizontal title="Pregenerated Wallets Guide" imgUrl="/images/v3/feature-pregeneration.png" href="/v3/server/guides/pregen" description="Learn how to implement pregenerated wallets for server-side operations" />

## Examples

Explore our example implementations of the Para Server SDK across different runtime environments:

<Card horizontal title="Examples" imgUrl="/images/v3/general-examples.png" href="/v3/server/examples" description="Complete Node.js implementation demonstrating session import and server-side signing" />

## Troubleshooting

If you encounter issues while setting up the Para Server SDK, check out our troubleshooting guide:

<Card horizontal title="Troubleshooting Guide" imgUrl="/images/v3/general-help.png" href="/v3/general/troubleshooting" description="Common issues and solutions for the Para Server SDK" />

## Next Steps

Once your Para Server SDK is set up and authenticated, you can start performing blockchain operations. The server SDK
provides the same functionality as the client SDK, allowing you to:

<CardGroup cols={3}>
  <Card title="EVM Integration" imgUrl="/images/v3/network-evm.png" href="/v3/server/guides/evm" description="Use Para with Ethers and other EVM-compatible libraries on the server." />

  <Card title="Solana Integration" imgUrl="/images/v3/network-solana.png" href="/v3/server/guides/solana" description="Integrate Para with Solana libraries in server environments." />

  <Card title="Cosmos Integration" imgUrl="/images/v3/network-cosmos.png" href="/v3/server/guides/cosmos" description="Use Para with CosmJs on the server." />

  <Card title="Stellar Integration" imgUrl="/images/v3/network-stellar.png" href="/v3/server/guides/stellar" description="Use Para with the Stellar SDK on the server." />
</CardGroup>
