Vercel Deployment

Deploy DocLayer to Vercel via UI, CLI, or CI

Vercel might an excellent choice for deploying your DocLayer application. It offers high speed, affordability, an extensive set of features, and a robust content delivery network - making it ideal for content-driven projects. We've prepared a seamless process to help you deploy your project quickly and easily on Vercel.

There are three ways to do so: Vercel Automation Panel, manually, and CD Pipeline. Choose the option that best suits your needs. Below, we've described how to set up your project for each deployment method.

Read the docs first

As the deployment process can vary, please read this documentation first - steps and their order may be different for your situation and scenario. Collect all necessary information before proceeding.

Create

Firstly you need to connect your project within the Vercel platform.

  • Use Vercel UI. Simply use Vercel’s UI and follow the prompts to connect Vercel with your Github - it will ask you to authorize your account and select your project’s repository. This makes your deployments automatic, with builds triggered on every commit for both production and preview instances.
Vercel Project Connect - DocLayer.dev
Vercel Project Connect Panel
  • Use the official Vercel CLI. This option is a bit more manual, but it gives you greater control over each action you take to deploy your project to the Vercel platform. You'll need to install the CLI on your machine.
# install vercel CLI globally(p)npm i -g vercel# login to the platform from your terminalvercel login# add your new projectvercel project add

The interface may prompt you to select an existing project to connect, if available. You can either choose one of the existing projects or create a new one as shown above. This flow might be ideal if you don't want to connect Vercel with your GitHub account - for various reasons.

Build

To build your project - whether using the Vercel platform, manually, or with a CI/CD pipeline - you’ll need to adjust your setup slightly. Follow the steps below to prepare your project for deployment on Vercel.

Install dl-vercel Module

To handle Vercel's static project structure, optimize the assets and connect your project automatically, we've built a dedicated module to use with the application. Install it first.

pnpm add @vuehouse/dl-vercel

Then register it within your nuxt.config.ts file.

export default defineNuxtConfig({  // the rest of the config  modules: ['@vuehouse/dl-vercel' /* the rest of modules */],  dlVercel: {    projectId: '<your_project_id>',    orgId: '<your_organization_id>',  },});

Both IDs can be retrieved from the Vercel panel. You don't need to add the IDs though - if they're not provided, the Vercel CLI will prompt you to connect your project during deployment.

Set dedicated preset

This step is optional; however, if you have any serverless functions (Nuxt Server Handlers), you need to add them to your build script as a Vercel preset.

{  "scripts": {    "build": "pnpm build",    "build:vercel": "nuxt build --preset=vercel"  }}

This ensures that Nitro prepares your server endpoints for deployment as Vercel serverless functions (with special structure).

Be aware that the Vercel-dedicated build will be assembled in a different structure than the regular build, with assets and serverless function handlers prepared specifically for Vercel’s infrastructure. As a result, this build cannot be previewed locally. To preview the app locally, use the regular build command instead.

Build the project

If you're deploying manually, run the pnpm build command in your terminal. This will build the application into the dedicated .vercel folder in your project root.

If you're using automatic deployment through the Vercel platform, specify the build command in the appropriate field when setting up your project. Remember to push your changes to the repository.

Vercel Project Settings - DocLayer.dev
Vercel Project Settings Panel
Step 0 of 0

Deploy

Now it's time to deploy your app. As mentioned before, you have three options for running your deployment process: you can rely on automatic deployments managed by the Vercel platform (if your project is connected to GitHub), deploy manually using the CLI, or use a CI/CD pipeline. Let's dive into each option to find the best one for you.

Automatic

Everything mentioned previously stays current. If you connect your project on GitHub to Vercel, each commit to your production or feature branch will automatically trigger a deployment - either as a preview or as your final production version. All you need is to complete the setup as shown above. More about setting your project with Vercel Platform you can read here.

Manual

Once your project has been built, you can use the Vercel CLI to deploy it manually from your terminal. Simply use the following commands based on your target environment:

# deploy as preview buildvercel deploy --prebuilt# deploy as production buildvercel deploy --prebuilt --prod

Run these commands from the project root folder. This will use the already built app (the --prebuilt flag ensures this), upload it to Vercel, and as a final the URL for your preview or production deployment will be printed in the terminal.

CI/CD

If you want to automate your deployment in a similar way to connecting your GitHub repository directly to Vercel - but without actually connecting it - you can set up a CI/CD pipeline in your project to achieve the same results. Below is a sample workflow you can customize to fit your needs. Add it to the .github/workflows folder in the root of your project.

name: Build & Deploy (Vercel)on:  push:    # trigger action on push to develop branch    branches: [develop]jobs:  build-and-deploy:    runs-on: ubuntu-latest    steps:      - name: Checkout repository        uses: actions/checkout@v4      - name: Setup pnpm        uses: pnpm/action-setup@v4      - name: Setup Node.js        uses: actions/setup-node@v4        with:          node-version-file: .nvmrc          cache: pnpm      - name: Install dependencies        run: pnpm install --frozen-lockfile      - name: Build Docs (apps/docs)        env:          DL_VERCEL_PROJECT_ID: ${{ vars.DL_VERCEL_PROJECT_ID }}          DL_VERCEL_ORG_ID: ${{ vars.DL_VERCEL_ORG_ID }}          DL_VERCEL_PROJECT_NAME: ${{ vars.DL_VERCEL_PROJECT_NAME }}          NODE_OPTIONS: --max-old-space-size=4096        run: |          pnpm prepare:app          pnpm build:app:vercel      - name: Install Vercel CLI        run: npm install -g vercel@latest      - name: Deploy to Vercel (prebuilt app)        id: deploy        env:          PROD_FLAG: ${{ github.ref == 'refs/heads/develop' && '--prod' || '' }}        run: |          echo "🔗 Linking Vercel project"          if ! vercel link --yes --project ${{ vars.DL_VERCEL_PROJECT_NAME }} --token=${{ secrets.VERCEL_TOKEN }}; then            echo "::error::Vercel linking failed"            exit 1          fi          echo "🚀 Running Vercel deploy"          deploy_log=$(mktemp)          # errexit would abort before the CLI status can be checked, and a          # pipeline's status is grep/tee rather than vercel when the URL is printed.          set +e          vercel deploy \            --prebuilt \            $PROD_FLAG \            --yes \            --archive=tgz \            --cwd . \            --name ${{ vars.DL_VERCEL_PROJECT_NAME }} \            --token=${{ secrets.VERCEL_TOKEN }} 2>&1 | tee "$deploy_log"          deploy_status=${PIPESTATUS[0]}          set -e          if [ "$deploy_status" -ne 0 ]; then            echo "::error::Vercel deploy failed with exit code $deploy_status"            exit "$deploy_status"          fi          DEPLOYMENT_URL=$(grep -oE 'https://[^[:space:]]+\.vercel\.app' "$deploy_log" | head -n 1 || true)          if [ -z "$DEPLOYMENT_URL" ]; then            echo "::error::Vercel deploy did not return a deployment URL"            exit 1          fi          # Set deployment URL based on environment          if [ "$PROD_FLAG" = "--prod" ]; then            DEPLOYMENT_URL="${{ vars.PRODUCTION_URL }}"            echo "✅ Production deployment done at: $DEPLOYMENT_URL"          else            echo "✅ Preview deployment done at: $DEPLOYMENT_URL"          fi          # Output the final deployment URL          echo "deployment_url=$DEPLOYMENT_URL" >> $GITHUB_OUTPUT

This action will be triggered whenever you push to the repository, according to the rules defined at the beginning. You will need a VERCEL_TOKEN, which you can generate in your Vercel Dashboard. Be sure to add it as a secret in your repository, as it is confidential.