deployEdit this page

Vercel

To deploy to Vercel, use the @lazarv/react-server-adapter-vercel package. This adapter is specifically designed to work with Vercel and it's 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.

After you have initialized your project, you can add the @lazarv/react-server-adapter-vercel package to your project:

pnpm add -D @lazarv/react-server-adapter-vercel

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

export default {
  adapter: '@lazarv/react-server-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: ['@lazarv/react-server-adapter-vercel', {
    serverlessFunctions: {
      index: {
        memory: 1024,
        maxDuration: 10,
        // ...
      },
    }
  }],
};

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 exec 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 exec 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 @lazarv/react-server-adapter-vercel package yet. Please, stay tuned for updates!