Skip to content

Vercel Reference

Vercel is optimized for modern web frameworks and serverless deployment:

  • ⚛️ Next.js - First-class support (same company)
  • 🚀 React/Vue/Svelte - All supported
  • 🔥 Serverless Functions - Built-in API routes
  • Edge Runtime - Global performance
domains/username.json
{
"owner": {
"username": "username",
"email": "user@example.com"
},
"records": {
"CNAME": "cname.vercel-dns.com"
}
}
Project TypeCNAME Target
Standardcname.vercel-dns.com
Customproject-name.vercel.app
EnterpriseCustom CNAME provided
Terminal window
# Via CLI
npm i -g vercel
vercel
# Or connect GitHub repo via dashboard
  1. Dashboard → Select project
  2. SettingsDomains
  3. Addusername.loves-to.dev
  4. Vercel shows CNAME target
  5. Use that target in your JSON file
  • Vercel auto-verifies within minutes
  • SSL certificate provisions automatically
  • Status shown in dashboard
next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'export', // For static export
trailingSlash: true,
images: {
unoptimized: true // For static export
}
}
module.exports = nextConfig
vite.config.js
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
base: '/', // Important for custom domains
build: {
outDir: 'dist'
}
})
astro.config.mjs
import { defineConfig } from 'astro/config';
export default defineConfig({
site: 'https://username.loves-to.dev',
output: 'static',
adapter: vercel()
});
Vercel Dashboard → Settings → Environment Variables
NODE_ENV=production
NEXT_PUBLIC_SITE_URL=https://username.loves-to.dev
API_BASE_URL=https://username.loves-to.dev/api
.env.local
NEXT_PUBLIC_SITE_URL=http://localhost:3000
API_BASE_URL=http://localhost:3000/api
pages/api/hello.js
export default function handler(req, res) {
res.status(200).json({
message: 'Hello from loves-to.dev!',
timestamp: new Date().toISOString(),
method: req.method
});
}
pages/api/edge-example.js
export const config = {
runtime: 'edge',
}
export default async function handler(req) {
return new Response(
JSON.stringify({
location: req.geo?.city || 'Unknown',
country: req.geo?.country || 'Unknown'
}),
{
status: 200,
headers: {
'content-type': 'application/json',
},
}
)
}
vercel.json
{
"buildCommand": "npm run build",
"outputDirectory": "dist",
"framework": "nextjs",
"functions": {
"pages/api/**/*.js": {
"maxDuration": 10
}
},
"headers": [
{
"source": "/(.*)",
"headers": [
{
"key": "X-Frame-Options",
"value": "DENY"
}
]
}
]
}
next.config.js
module.exports = {
images: {
domains: ['username.loves-to.dev'],
formats: ['image/webp', 'image/avif'],
},
}
vercel.json
{
"headers": [
{
"source": "/static/(.*)",
"headers": [
{
"key": "Cache-Control",
"value": "public, max-age=31536000, immutable"
}
]
}
]
}
pages/_app.js
import { Analytics } from '@vercel/analytics/react';
export default function App({ Component, pageProps }) {
return (
<>
<Component {...pageProps} />
<Analytics />
</>
);
}
  • Built-in error tracking in dashboard
  • Real-time function logs
  • Performance metrics included
  • Check Node.js version compatibility
  • Verify all dependencies are listed
  • Review build logs in dashboard
  • Ensure CNAME points to correct target
  • Wait up to 48 hours for DNS propagation
  • Contact Vercel support if stuck
  • Hobby plan: 10 seconds max
  • Pro plan: 60 seconds max
  • Optimize function performance