@/ — that maps to the src/ directory. This lets you write clean, location-independent imports throughout the codebase.
What the alias does
Instead of traversing the directory tree with relative paths:Where it’s configured
The alias is declared in two places so both the Vite bundler and the TypeScript compiler understand it.Vite configuration
Vite resolves the alias at build time and during the dev server:vite.config.ts
TypeScript configuration
Thepaths field in tsconfig.app.json tells the TypeScript compiler where @/ points, enabling type checking and editor auto-complete:
tsconfig.app.json
How to use it
Prefix any import from thesrc/ directory with @/:
@/ to src/, so @/components/ui/button becomes src/components/ui/button.
The
@/ alias only works for files inside src/. Files at the project root (like vite.config.ts itself) must still use regular relative or Node.js path imports.Add more aliases
If you want additional aliases (for example, a shorthand for a deeply nested directory), add entries to both config files.Why use aliases
| Problem with relative imports | Benefit of aliases |
|---|---|
| Break when you move a file | Stable across refactors |
Hard to read (../../../) | Clear and self-documenting |
| IDE auto-import uses relative paths | Editors respect paths and suggest aliases |
| Inconsistent across the codebase | One canonical import form for every module |