All Projects → nuxt → Vercel Builder

nuxt / Vercel Builder

Licence: mit
Vercel Builder for Nuxt.js

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Vercel Builder

now-nuxt
A Now v2 Nuxt builder
Stars: ✭ 25 (-94.28%)
Mutual labels:  nuxt, now, zeit, nuxtjs
Now Builders
Official Now Builders created by the ZEIT team
Stars: ✭ 483 (+10.53%)
Mutual labels:  serverless, now, zeit
Jwt Example
Playing with user registration, login/logout, auth, etc using JWTs, serverless functions & faunadb as the data store.
Stars: ✭ 22 (-94.97%)
Mutual labels:  serverless, now, zeit
Nuxt7
📱 Full Featured iOS & Android PWA Apps with Nuxt.js and Framework7
Stars: ✭ 282 (-35.47%)
Mutual labels:  nuxt, nuxtjs
Nuxt Webfontloader
Efficient web font loading has never been easier!
Stars: ✭ 264 (-39.59%)
Mutual labels:  nuxt, nuxtjs
Nuxt Ssr Firebase
Nuxt.js Universal App with SSR via Firebase Functions and Firebase Hosting
Stars: ✭ 273 (-37.53%)
Mutual labels:  nuxt, nuxtjs
nuxt wp
Repo for my blog series on a building a site with WordPress REST API, Vue, and Nuxt.js
Stars: ✭ 41 (-90.62%)
Mutual labels:  nuxt, nuxtjs
Blog Front
blog-front @nuxt
Stars: ✭ 305 (-30.21%)
Mutual labels:  nuxt, nuxtjs
Graphcms Examples
Example projects to help you get started with GraphCMS
Stars: ✭ 295 (-32.49%)
Mutual labels:  nuxt, nuxtjs
Nuxt Material Admin
Vue-CLI Boilerplate based on Nuxt and vue-material-admin template.
Stars: ✭ 310 (-29.06%)
Mutual labels:  nuxt, nuxtjs
Nuxt Purgecss
Drop superfluous CSS! A neat PurgeCSS wrapper for Nuxt.js
Stars: ✭ 356 (-18.54%)
Mutual labels:  nuxt, nuxtjs
nuxt-star-admin-extra
Admin Template base on Vue StarAdmin with improved on design and served using Nuxt.js
Stars: ✭ 19 (-95.65%)
Mutual labels:  nuxt, nuxtjs
admin-null-nuxt
Admin Null — Free Nuxt Bulma Admin Dashboard (with dark mode)
Stars: ✭ 39 (-91.08%)
Mutual labels:  nuxt, nuxtjs
Awesome Nuxt
A curated list of awesome things related to Nuxt.js
Stars: ✭ 4,285 (+880.55%)
Mutual labels:  nuxt, nuxtjs
test-utils
Test utilities for Nuxt.js
Stars: ✭ 100 (-77.12%)
Mutual labels:  nuxt, nuxtjs
Covid19 Brazil Api
API com dados atualizados sobre o status do COVID-19 🦠
Stars: ✭ 300 (-31.35%)
Mutual labels:  now, zeit
Vue Notion
A fast Vue renderer for Notion pages
Stars: ✭ 343 (-21.51%)
Mutual labels:  nuxt, nuxtjs
Vue Gallery
📷 Responsive and customizable image and video gallery, carousel and lightbox, optimized for both mobile and desktop web browsers.
Stars: ✭ 405 (-7.32%)
Mutual labels:  nuxt, nuxtjs
Vercel Php
▲ Vercel PHP runtime • vercel-php • now-php • 🐘+ λ = ❤
Stars: ✭ 429 (-1.83%)
Mutual labels:  now, zeit
k-domains
A simple module to manage multiple subdomains with just one project
Stars: ✭ 41 (-90.62%)
Mutual labels:  nuxt, nuxtjs

vercel-builder

Nuxt Vercel Builder

npm version npm downloads packagephobia Github actions status Codecov Dependencies Standard JS

This Vercel builder takes a Nuxt application defined by a nuxt.config entrypoint and deploys it as a serverless function in a Vercel environment.

It features built-in caching of node_modules and the yarn global cache (even with dependency changes!) and multi-stage build for fast and small deployments.

When to use it

If you are using Vercel and need SSR rendering, @nuxtjs/vercel-builder is the ideal way to ship a fast, production-ready Nuxt application that scales automatically.

If you do not need SSR rendering, consider deploying a statically generated Nuxt application instead. See this guide from Vercel for more information.

You can also find more information on the Nuxt website.

How to use it

The first step is to set up a Nuxt project.

To get started, make sure you have installed the Nuxt dependencies with the following command:

yarn add nuxt

Then, in your project directory, create a pages directory with some example pages, for example; the home index page, pages/index.vue:

<template>
  <div>
    Works!
  </div>
</template>

Create a simple nuxt.config.js file:

export default {
  head: {
    title: "My Nuxt Application!"
  }
};

Then define the build in vercel.json:

{
  "version": 2,
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/vercel-builder"
    }
  ]
}

Upon deployment, you will get a URL like this: https://nuxtjs-8fnzfb1ci.vercel.app

See Basic example for a more complete deployable example, including an example of how to set up vercel dev support.

See Deploying two Nuxt apps side-by-side for details on deploying two Nuxt apps in one monorepo.

Using with TypeScript

vercel-builder supports TypeScript runtime compilation, though it does so in a slightly different way from @nuxt/typescript-runtime. It adds in a pre-compilation step as part of building the lambda for files not compiled by Webpack, such as nuxt.config.ts, local modules and serverMiddleware.

References to original TS files in strings outside of modules or serverMiddleware may therefore cause unexpected errors.

Configuration

serverFiles

  • Type: Array

If you need to include files in the server lambda that are not built by webpack or within static/, such as a local module or serverMiddleware, you may specify them with this option. Each item can be a glob pattern.

Example:

{
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/vercel-builder",
      "config": {
        "serverFiles": ["server-middleware/**"]
      }
    }
  ]
}

internalServer

  • Type: Boolean
  • Default: false

If you have defined serverMiddleware in your nuxt.config, this builder will automatically enable an internal server within the lambda so you can access your own endpoints via http://localhost:3000. (This does not affect how you call your endpoints from client-side.)

If you need to enable or disable the internal server manually (for example, if you are adding server middleware via a module), just set internalServer within the builder options.

generateStaticRoutes

  • Type: Boolean
  • Default: false

To pre-render routes during the build using nuxt generate set this to true. Routes that are not generated will fallback to the server lambda. You will need to specify the routes to be generated in your nuxt.config.

Example:

{
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/vercel-builder",
      "config": {
        "generateStaticRoutes": true
      }
    }
  ]
}

tscOptions

  • Type: Object

If you need to pass TypeScript compiler options to override your tsconfig.json, you can pass them here. See the TypeScript documentation for valid options. Example:

{
  "src": "nuxt.config.ts",
  "use": "@nuxtjs/vercel-builder",
  "config": {
    "tscOptions": {
      "sourceMap": false
    }
  }
}

You can also include a tsconfig.vercel.json file alongside your tsconfig.json file. The compilerOptions from those files, along with any tscOptions passed through vercel.json, will be merged and the resulting options used to compile your nuxt.config.ts, local modules and serverMiddleware.

Technical details

Dependency installation

Package dependencies are installed with either npm (if a package-lock.json is present) or yarn.

NOTE: Using yarn is HIGHLY recommended due to its autoclean functionality , which can decrease lambda size.

Monorepos

Just enable the "Include source files outside of the Root Directory in the Build Step" option in the Root Directory section within the project settings.

Vercel monorepo config

Private npm modules

To install private npm modules, define NPM_AUTH_TOKEN or NPM_TOKEN as a build environment variable in vercel.json.

Alternatively, you can inline your entire .npmrc file in a NPM_RC environment variable.

Node version

The Node version used is the latest 14.x release. Alternatively, you can specify Node 12 or 10 in your package.json - see Vercel documentation.

vercel-build script support

This builder will run a given custom build step if you have added a vercel-build key under scripts in package.json.

Troubleshooting

Environment variables

Because of Nuxt' approach to environment variables, environment variables present at build time will be compiled into the lambda. They may also be required at runtime, depending on how you are consuming them.

You may, therefore, need to include them in your vercel.json in both the env and build.env keys (see Vercel documentation). For example:

  "env": {
    "MY_VARIABLE": true
  },
  "build": {
    "env": {
      "MY_VARIABLE": true
    }
  }

If you are using Nuxt 2.13+, it is recommended to use the new runtimeConfig options which can decrease this duplication by only requiring that you set the variable once:

  "env": {
    "MY_VARIABLE": true
  }

License

MIT License

Documentation and builder inspired by Next.js by Vercel

Copyright (c) Nuxt Community

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].