DeployEdit this page

Vercel

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

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

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:

export default {
  adapter: 'vercel',
};

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:

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

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

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 part of the Vercel Primitives section of the Vercel Build Output API documentation.

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

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:

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!