惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

雷峰网
雷峰网
宝玉的分享
宝玉的分享
I
InfoQ
P
Privacy International News Feed
V
V2EX
IT之家
IT之家
S
SegmentFault 最新的问题
D
Darknet – Hacking Tools, Hacker News & Cyber Security
V2EX - 技术
V2EX - 技术
C
CERT Recently Published Vulnerability Notes
C
Check Point Blog
The Register - Security
The Register - Security
爱范儿
爱范儿
博客园 - 三生石上(FineUI控件)
AWS News Blog
AWS News Blog
M
MIT News - Artificial intelligence
C
Cyber Attacks, Cyber Crime and Cyber Security
F
Fortinet All Blogs
B
Blog
N
Netflix TechBlog - Medium
B
Blog RSS Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Last Week in AI
Last Week in AI
T
Threatpost
Forbes - Security
Forbes - Security
U
Unit 42
A
Arctic Wolf
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
P
Palo Alto Networks Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Recorded Future
Recorded Future
L
Lohrmann on Cybersecurity
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
月光博客
月光博客
Spread Privacy
Spread Privacy
MongoDB | Blog
MongoDB | Blog
Jina AI
Jina AI
I
Intezer
V
Visual Studio Blog
阮一峰的网络日志
阮一峰的网络日志
The Hacker News
The Hacker News
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
L
LangChain Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
博客园_首页
MyScale Blog
MyScale Blog
腾讯CDC
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
量子位

Vercel News

Vercel Open Source Program: Winter 2026 cohort How Notion Workers run untrusted code at scale with Vercel Sandbox How we run Vercel's CDN in front of Discourse From idea to secure checkout in minutes with Stripe Building Slack agents can be easy Scaling redirects to infinity on Vercel Advancing Python typing Gamma builds design-first agents with Vercel How Avalara turns pipe dreams into patent-pending with v0 Keeping community human while scaling with agents How OpenEvidence built a healthcare AI that physicians actually trust Security boundaries in agentic architectures Skills Night: 69,000+ ways agents are getting smarter Video Generation with AI Gateway We Ralph Wiggumed WebStreams to make them 10x faster How Stably ships AI testing agents in hours, not weeks How we built AEO tracking for coding agents Anyone can build agents, but it takes a platform to run them Introducing Geist Pixel The Vercel AI Accelerator is back with $6m in credits Making agent-friendly pages with content negotiation The Vercel OSS Bug Bounty program is now available Introducing the new v0 Run untrusted code with Vercel Sandbox, now generally available How Stripe built a game-changing app in a single flight with v0 How Sensay went from zero to product in six weeks AGENTS.md outperforms skills in our agent evals Agent skills explained: An FAQ Testing if "bash is all you need" AWS databases are now live on the Vercel Marketplace and v0 Use Perplexity Web Search with Vercel AI Gateway Introducing: React Best Practices Nick Bogaty joins Vercel as Chief Revenue Officer How Mux shipped durable video workflows with their @mux/ai SDK How to build agents with filesystems and bash How we made v0 an effective coding agent Stopping the slow death of internal tools Building AI-Generated Pixel Trading Cards with Vercel AI Gateway We removed 80% of our agent’s tools AI SDK 6 Our $1 million hacker challenge for React2Shell Cline now runs on Vercel AI Gateway How to prompt v0 Build smarter workflows with Notion and v0 Vercel launches partner certification Inside Workflow DevKit: How framework integrations work React2Shell Security Bulletin | Vercel Knowledge Base Billions of requests: Black Friday-Cyber Monday 2025 Investing in the Python ecosystem AWS Databases coming to the Vercel Marketplace How we built the v0 iOS app Workflow Builder: Build your own workflow automation platform Vercel Open Source Program: Fall 2025 cohort Self-driving infrastructure Vercel collaborates with Google for Gemini 3 Pro Preview launch Vercel: The anti-vendor-lock-in cloud How Nous Research used BotID to block automated abuse at scale How AI Gateway runs on Fluid compute What we learned building agents at Vercel Build and deploy data applications on Snowflake with v0 BotID Deep Analysis catches a sophisticated bot network in real-time Vercel achieves TISAX AL2 compliance to serve automotive partners Bun runtime on Vercel Functions David Totten Joins Vercel to Lead Global Field Engineering Vercel Ship AI 2025 recap You can just ship agents AI agents and services on the Vercel Marketplace Built-in durability: Introducing Workflow Development Kit Zero-config backends on Vercel AI Cloud Introducing Vercel Agent: Your new Vercel teammate Update regarding Vercel service disruption on October 20, 2025 Agents at work, a partnership with Salesforce and Slack Running Next.js in ChatGPT: How to Build ChatGPT Apps Talha Tariq joins Vercel as CTO of Security Just another (Black) Friday Server rendering benchmarks: Fluid Compute and Cloudflare Workers Towards the AI Cloud: Our Series F Collaborating with Anthropic on Claude Sonnet 4.5 to power intelligent coding agents Preventing the stampede: Request collapsing in the Vercel CDN BotID uncovers hidden SEO poisoning How we made global routing faster with Bloom filters What you need to know about vibe coding Scale to one: How Fluid solves cold starts Addressing security & quality issues with MCP tools - Vercel AI agents at scale: Rox’s Vercel-powered revenue operating system Agentic Infrastructure Zero Data Retention on AI Gateway Optimizing Vercel Sandbox snapshots How Waldium made a blog platform work for humans and AI alike How FLORA shipped a creative agent on Vercel's AI stack Agent responsibly Making Turborepo 96% faster with agents, sandboxes, and humans Unified reporting for all AI Gateway usage new.website joins forces with v0 SERHANT.'s playbook for rapid AI iteration Two startups at global scale without DevOps Chat SDK brings agents to your users 360 billion tokens, 3 million customers, 6 engineers Meet the 2026 Vercel AI Accelerator Cohort Build knowledge agents without embeddings
Custom fonts without compromise using Next.js and `next/font` - Vercel – Vercel
2023-03-28 · via Vercel News

3 min read

Highly optimized, self-hosted fonts with just a few lines of code.

As web developers, we know the importance of typography in design. Custom fonts can set the tone for a website and enhance its overall aesthetic. However, using custom fonts can often create issues with website performance and user experience.

One of the biggest issues with custom fonts is the Cumulative Layout Shift (CLS) that occurs when a font takes too long to load. These Flashes of Unstyled Content (FOUC) can alter the positioning of elements already on the page and make it difficult to navigate. CLS and FOUC can also impact an application's search engine ranking.

On Vercel’s external websites, we used to solve these problems with the workarounds that we’ll talk about below. However, with the release of Next.js 13, we switched to next/font, which cut down on complex code, client-side JavaScript, and layout shift.

Get started

This Next.js 13 template, with `next/font` ready to go in `pages/index.js`, can give you a jumpstart on conquering layout shift.

Deploy

Link to headingBefore next/font

At vercel.com and nextjs.org, we were optimizing our font loading in a few key ways:

  1. We hosted our font ourselves, instead of using a third-party URL like Google Fonts.

  2. We preloaded the font using <meta> tags.

  3. We only preloaded the Latin subset of characters. This is enough for English, and other subsets could still load in as needed.

  4. We specified fallback fonts that looked as similar as possible to our desired font. This included fonts that weren’t technically “web safe,” but were still available on many users’ devices.

  5. We set the font-display CSS property to optional so that the text on the page wouldn’t flicker and cause layout shift if it loaded late.

  6. We used client-side JavaScript to detect if a user has visited Vercel's site before, and if not, we served them the fallback font for a zero layout-shift experience.

As you might guess, these optimizations took some complex workarounds in the codebase.

Here’s the relevant code from the return statement of our old next/head, which was rendered on every page:

components/head.tsx

<script

dangerouslySetInnerHTML={{

__html: `

if (!window.newVisit && document.cookie && document.cookie.indexOf('beenHere=1') !== -1) {

document.documentElement.classList.add('inter')

} else {

window.newVisit=true

}

setTimeout(function() {

document.cookie='beenHere=1;samesite=lax;expires='+

new Date(Date.now()+31*3600*24*1000).toGMTString()

})`,

}}

/>

<link

as="font"

crossOrigin="anonymous"

href="https://assets.vercel.com/raw/upload/v1660068731/fonts/4/Inter.var.latin.woff2"

rel="preload"

type="font/woff2"

/>

Custom font solution used by Vercel before `next/font`.

And here’s code from our old CSS:

:root {

--font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto',

'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',

sans-serif;

}

:root.inter {

--font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto',

'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',

sans-serif;

}

Custom font CSS used by Vercel before `next/font`.

In addition to these adjustments, we also optimized the font through manual subsetting, such as the example below:

@font-face {

font-family: 'Inter';

font-style: normal;

font-weight: 100 900;

font-display: optional;

src: url('https://assets.vercel.com/raw/upload/v1660068731/fonts/4/Inter.var.latin.woff2')

format('woff2');

unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,

U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212,

U+2215, U+FEFF, U+FFFD;

}

/* Plus eight more @font-face definitions for other languages and characters. */

@font-face rules to manually subset the font before we used `next/font`.

As you can imagine, we’d need to adjust and lengthen the code for any new fonts we wished to add.

Link to headingEnter next/font

With far less code, next/font reliably incorporates all the optimizations mentioned above for either third-party or first-party fonts. Automatic self-hosting—which means total elimination of external network requests—contributes to the bulk of the magic. Plus, your self-hosted font file is further optimized to preload only the characters your website needs.

Where next/font takes it a step further is preventing layout shift entirely. It calculates the size-adjust property based on the actual font files (.ttf or .woff2, for example), making the calculation available on the server before the font is even requested. This allows next/font to generate a fallback font that matches the spacing of your custom font, ensuring a seamless swap.

To fully leverage the fallback font, we set display: "swap" when configuring the font object. This just allows the browser to swap the custom font in, even if it's slow to load.

In total, here’s what the new code looks like:

lib/font.ts

import { Inter } from 'next/font/google';

const interFont = Inter({

display: 'swap',

subsets: ['latin'],

variable: '--font-sans',

});

export const interFontClass = interFont.variable;

The current code for Vercel's custom fonts is drastically reduced with `next/font`.

We can then easily add new fonts and use this one throughout our site as needed. You’ll notice we used the variable property, which allows us to reference the variable without changing our existing CSS. You can also use this for easy integration with TailwindCSS in your own project.

Check out the video below for a full demonstration of next/font:

next/font is now included in Next.js 13, so no additional installation is required. This also means when importing, you can drop the @ in front of next/font.

Additionally, when using the new Next.js 13 App Router, you can place font imports in specific layouts, only preloading fonts you need for specific pages the user navigates to. Do take care to import your font in the highest common layout for all pages that need it, to avoid loading in multiple instances of the font.

Link to headingBring your own fonts

Web typography has significant impact on a website's overall design and user experience. Custom fonts bring out your brand’s uniqueness, and with next/font, you don’t have to worry about all the baggage that used to come with them.

If you're ready to enhance your own applications’s typographical performance, get started with the documentation on next/font.

Want to talk to an expert?

Brainstorm with our team about your unique use case of Next.js.

Send us a message