---
title: "next/font loader not called at module scope (perf/font-module-scope)"
description: "next/font is resolved at build time: the loader must be called at the top level of the module and assigned to a const, or the build fails."
url: http://localhost:4173/rules/perf/font-module-scope
updated: 2026-11-11
---

# next/font loader not called at module scope

> `perf/font-module-scope` is a vetd rule. It flags: next/font loader not called at module scope. It runs on every `check`, together with the TypeScript check.

| Fact | Value |
| --- | --- |
| Rule id | `perf/font-module-scope` |
| Severity | error |
| Group | Performance: fonts, images, scripts and bundle |
| Tags | nextjs-16, correctness |

## Why it matters

next/font is resolved at build time: the loader must be called at the top level of the module and assigned to a const, or the build fails.

## How to fix it

const font = Inter({ subsets: ["latin"] }) at module scope, then use font.className in components.

## Credit

Based on work by:

- [Next.js team](https://nextjs.org): The font loader is resolved at build time, so it must be called at module scope and assigned to a const.

## References

- [Font Module](https://nextjs.org/docs/app/api-reference/components/font), Next.js
- [Font Optimization](https://nextjs.org/docs/app/getting-started/fonts), Next.js

## See it

Demos in the vetd Lab:

- [Load fonts with next/font](http://localhost:4173/lab/nextjs/next-font)

## Related rules

- [`perf/font-subsets`](http://localhost:4173/rules/perf/font-subsets.md)
- [`perf/font-duplicate`](http://localhost:4173/rules/perf/font-duplicate.md)

## Get this text from vetd

MCP: call `explain` with `{ "diagnosticId": "perf/font-module-scope" }`. CLI: `npx vetd explain perf/font-module-scope`.

---

[All 92 rules](http://localhost:4173/rules.md) · Previous: [`perf/font-subsets`](http://localhost:4173/rules/perf/font-subsets.md) · Next: [`perf/font-weights`](http://localhost:4173/rules/perf/font-weights.md)
