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

# Server uploads

> Learn how to upload files from your server to Restash.

Easily upload files from a Node.js server to Restash.
This guide shows you how to set up server-side uploads using our lightweight SDK.

> [!NOTE]
>
> You can only upload files up to 4MB on the server. If you want to upload files larger than 4MB,
> you can use the client side SDK to upload files directly from the browser.

## Prerequisites

To follow this guide, you will need to:

* [Create a Restash account](https://restash.io/register)
* [Create an API key](https://restash.io/api-keys)

## Install and initialize Restash

**1. Install**

Install Restash Node using your preferred package manager.

```bash npm theme={null}
npm i @restash/node
```

```bash pnpm theme={null}
pnpm i @restash/node
```

```bash yarn theme={null}
yarn add @restash/node
```

**2. Initialize Restash**

Initialize Restash with your **private API key**.

```javascript lib/restash.ts theme={null}
import { Restash } from "@restash/node";

export const restash = new Restash("sk_123456789");
```

**3. Use Restash anywhere in your server code**

You can now import Restash and use it to upload files.

```javascript theme={null}
import { restash } from "@/lib/restash";
```

## Uploading your first file on the server

In this example, we will upload a file inside a Next.js API route.

```typescript api/upload/route.ts theme={null}
import { NextResponse, NextRequest } from "next/server";
import { restash } from "@/lib/restash";

export const POST = async (req: NextRequest) => {
  const formData = await req.formData();
  const file = formData.get("file") as File;

  const upload = await restash.files.upload(file);

  // store the upload in your db or do something else with it
  console.log(upload.url);

  return NextResponse.json(upload);
};
```

## Next steps

Check out the full [Node.js SDK](https://documentation.restash.io/sdks/node.md) for more information on how to use the SDK.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.