# Vercel

To deploy to Vercel, use the built-in `vercel` adapter. This adapter is specifically designed to work with Vercel and its configuration.

## Installation

First you need to initialize your project with Vercel. You can do this by running the following command:

```sh
vercel project add <project-name>
vercel link --yes --project <project-name>
```

At this point you will have a `.vercel` directory with a `project.json` file in it. This file will be used to store the project and organization configuration for your Vercel project.

No additional packages are needed - the adapter is built into `@lazarv/react-server`.

Then you need to add the adapter to your `react-server.config.mjs` file:

```mjs
export default {
  adapter: 'vercel',
};
```

## Configuration

Configuration for this adapter will be added to your Vercel `config.json` file so you can use all available Vercel configuration options, like headers, redirects, and rewrites.

You can also override the Serverless Function configuration for the `index` function handling all of the server-side rendering by using the following adapter options:

```mjs
export default {
  adapter: ['vercel', {
    serverlessFunctions: {
      index: {
        memory: 1024,
        maxDuration: 10,
        // ...
      },
    }
  }],
};
```

Or disable serverless functions entirely if you only want static hosting:

```mjs
export default {
  adapter: ['vercel', {
    serverlessFunctions: false,
  }],
};
```

This configration will be created at `.vercel/output/functions/index.func/.vc-config.json` and you can learn more about the available options in the [Serverless Function configuration](https://vercel.com/docs/build-output-api/v3/primitives#serverless-function-configuration) part of the Vercel Primitives section of the Vercel Build Output API documentation.

## Deploy

When using `@lazarv/react-server` with the Vercel adapter, you can deploy your application to Vercel using the following command:

```sh
pnpm react-server build [root] # [root] is the entry point of your application
vercel deploy --prebuilt
```

You can also deploy with the `react-server` CLI by using the `deploy` argument:

```sh
pnpm react-server build [root] --deploy
```

This will build your application and deploy it to Vercel.

> Vercel Edge Functions, Edge Middlewares, Prerender Functions, ISR (Incremental Static Regeneration), Image Optimization and other Vercel features are not supported by the built-in Vercel adapter yet. Please, stay tuned for updates!