A Vercel build runtime for static websites and single-page applications with zero configuration.
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Specialized utilities for framework-specific optimizations including analytics plugin injection, environment variable handling, and build command detection for popular frontend frameworks.
Specialized utilities for Gatsby.js applications including Vercel analytics plugin injection and configuration management.
/**
* Injects gatsby-plugin-vercel into Gatsby configuration for analytics tracking
* @param dir - Gatsby project directory path
* @returns Promise that resolves when injection is complete
*/
function injectVercelAnalyticsPlugin(dir: string): Promise<void>;Usage Examples:
// Note: Import path may vary depending on build setup
// Internal: import * as GatsbyUtils from './utils/gatsby';
// External: import * as GatsbyUtils from '@vercel/static-build/utils/gatsby';
import * as GatsbyUtils from '@vercel/static-build/utils/gatsby';
// Inject Vercel analytics into Gatsby project
await GatsbyUtils.injectVercelAnalyticsPlugin("/project/gatsby-site");Gatsby Analytics Injection Process:
GATSBY_VERCEL_ANALYTICS_ID from VERCEL_ANALYTICS_IDgatsby-plugin-vercel as dependency if not presentgatsby-config.js with analytics plugin.js.__vercel_builder_backup__.jsGenerated gatsby-config.js:
const userConfig = require("./gatsby-config.js.__vercel_builder_backup__.js");
// Prefer default export handling
const preferDefault = m => (m && m.default) || m;
const vercelConfig = Object.assign({}, preferDefault(userConfig));
if (!vercelConfig.plugins) {
vercelConfig.plugins = [];
}
// Add Vercel analytics plugin if not already present
const hasPlugin = vercelConfig.plugins.find(
(p) => p && (p === "gatsby-plugin-vercel" || p.resolve === "gatsby-plugin-vercel")
);
if (!hasPlugin) {
vercelConfig.plugins = vercelConfig.plugins.slice();
vercelConfig.plugins.push({
resolve: "gatsby-plugin-vercel",
options: {},
});
}
module.exports = vercelConfig;Specialized utilities for Nuxt.js applications including web vitals analytics plugin injection.
/**
* Injects @nuxtjs/web-vitals plugin into Nuxt configuration for analytics tracking
* @param dir - Nuxt project directory path
* @returns Promise that resolves when injection is complete
*/
function injectVercelAnalyticsPlugin(dir: string): Promise<void>;Usage Examples:
// Note: Import path may vary depending on build setup
// Internal: import * as NuxtUtils from './utils/nuxt';
// External: import * as NuxtUtils from '@vercel/static-build/utils/nuxt';
import * as NuxtUtils from '@vercel/static-build/utils/nuxt';
// Inject Vercel analytics into Nuxt project
await NuxtUtils.injectVercelAnalyticsPlugin("/project/nuxt-app");Nuxt Analytics Injection Process:
.nuxtrc file with modules[] entry for @nuxtjs/web-vitals@nuxtjs/web-vitals as dependency if not presentrc9 library to safely update configurationGenerated .nuxtrc:
modules[]="@nuxtjs/web-vitals"Automatic framework detection system that identifies frameworks based on package.json dependencies and applies appropriate optimizations.
/**
* Detects framework from configuration and package.json dependencies
* @param config - Build configuration with optional framework override
* @param pkg - Package.json contents
* @returns Detected framework object or undefined
*/
function getFramework(
config: Config | null,
pkg?: PackageJson | null
): Framework | undefined;
interface Framework {
name: string;
slug: string | null;
logo: string;
darkModeLogo?: string;
screenshot?: string;
demo?: string;
tagline?: string;
website?: string;
description: string;
dependency?: string;
sort?: number;
useRuntime?: object;
ignoreRuntimes?: string[];
detectors?: object;
recommendedIntegrations?: any[];
defaultVersion?: string;
settings: {
buildCommand: SettingValue;
devCommand: SettingValue;
installCommand?: SettingValue;
outputDirectory?: SettingValue;
};
defaultRoutes?: Route[] | ((dirPrefix: string) => Promise<Route[]>);
cachePattern?: string | string[];
envPrefix?: string;
getOutputDirName?: (outputDirPrefix: string) => Promise<string>;
}
interface SettingValue {
value: string | null;
placeholder?: string;
}Framework Detection Process:
config.framework for explicit framework specificationpackage.json dependencies against known framework patternsSupported Frameworks (examples):
dependency: "next"dependency: "react-scripts"dependency: "gatsby"dependency: "nuxt"dependency: "@vue/cli-service"dependency: "@angular/cli"dependency: "@sveltejs/kit"Framework-specific environment variable injection and prefixing for client-side access.
Create React App Integration:
// Disable CI warnings that fail builds
if (framework?.slug === 'create-react-app') {
spawnOpts.env.CI = 'false';
}Framework Prefix Handling:
// Inject VERCEL_ environment variables with framework prefix
if (process.env.VERCEL_URL && framework.envPrefix) {
Object.keys(process.env)
.filter(key => key.startsWith('VERCEL_'))
.forEach(key => {
const newKey = `${framework.envPrefix}${key}`;
if (!(newKey in process.env)) {
process.env[newKey] = process.env[key];
}
});
}Framework Environment Prefixes:
GATSBY_ - Exposes variables to client-side bundlesNEXT_PUBLIC_ - Exposes variables to browserREACT_APP_ - Bundled into client codeIntelligent build command detection with framework-specific defaults and package.json script fallbacks.
/**
* Determines appropriate command for install, build, or dev operations
* @param name - Command type (install, build, dev)
* @param pkg - Package.json contents
* @param config - Build configuration
* @param framework - Detected framework
* @returns Command string or null
*/
function getCommand(
name: 'install' | 'build' | 'dev',
pkg: PackageJson | null,
config: Config,
framework: Framework | undefined
): string | null;
/**
* Gets script name from package.json with fallbacks
* @param pkg - Package.json contents
* @param cmd - Base command name
* @param config - Build configuration
* @returns Script name to execute
*/
function getScriptName(pkg: PackageJson, cmd: string, config: Config): string;
/**
* Checks if a script exists in package.json
* @param script - Script name to check
* @param pkg - Package.json contents
* @returns Whether the script exists
*/
function hasScript(script: string, pkg: PackageJson): boolean;Command Detection Priority:
config.buildCommand, config.devCommand, config.installCommandnow-build, vercel-build, build, dev, now-devExample Command Resolution:
// For Next.js framework
const buildCommand = getCommand('build', pkg, config, nextjsFramework);
// Returns: "next build" (from framework defaults)
const devCommand = getCommand('dev', pkg, config, nextjsFramework);
// Returns: "next dev" (from framework defaults)Framework-specific route generation for single-page applications and static sites.
/**
* Generates framework-specific routes for deployment
* @param framework - Framework configuration
* @param dirPrefix - Directory prefix for routes
* @returns Promise resolving to route array
*/
async function getFrameworkRoutes(
framework: Framework,
dirPrefix: string
): Promise<Route[]>;Framework Route Examples:
Next.js Routes:
[
{ src: '/api/(.*)', dest: '/api/$1' },
{ src: '/((?!api).+)', dest: '/$1.html' },
{ src: '/', dest: '/index.html' }
]Gatsby Routes:
[
{ src: '/(.*)', dest: '/$1.html' },
{ src: '/', dest: '/index.html' }
]Framework-specific development server handling with port management and proxy configuration.
Development Route Generation:
/**
* Creates development route for proxying to local dev server
* @param srcBase - Source base path
* @param devPort - Development server port
* @param route - Route configuration
* @returns Route with dev server proxy destination
*/
const getDevRoute = (srcBase: string, devPort: number, route: RouteWithSrc): RouteWithSrc;Development Flow:
Example Dev Route:
{
src: '/(.*)',
dest: 'http://localhost:3000/$1'
}Install with Tessl CLI
npx tessl i tessl/npm-vercel--static-build