Deploying an 8-Language Astro Site to Vercel: Lessons from 5000+ Static Routes
The Scale Our Marrakech transfer site serves content in eight languages: English, French, Spanish, German, Italian, Portuguese, Dutch, and Arabic (RTL). Multiply that by 80+ route pages, excursion pages, activity pages
The Scale
Our Marrakech transfer site serves content in eight languages: English, French, Spanish, German, Italian, Portuguese, Dutch, and Arabic (RTL). Multiply that by 80+ route pages, excursion pages, activity pages, guide articles, and utility pages, and you hit 5,000+ static routes at build time.
Locale Architecture
Each locale gets its own URL prefix except English (the default):
export const LOCALES = [
{ code: "en", dir: "ltr", hreflang: "en" },
{ code: "fr", dir: "ltr", hreflang: "fr" },
{ code: "ar", dir: "rtl", hreflang: "ar" },
// ... 5 more
];
A single splitLocalePath function handles routing: /fr/transfers/essaouira resolves to { locale: "fr", pathname: "/transfers/essaouira" }. English paths have no prefix.
Translation Dict Pattern
Each locale has a folder of TypeScript modules (dict/fr/routes.ts, dict/fr/ui.ts). A fill() helper merges the locale dict onto the English base, so untranslated keys fall back to English rather than rendering raw slugs:
function uiNs(locale: Locale, ns: string): Strings {
const en = peekDict("en")?.ui?.[ns] ?? {};
if (locale === "en") return en;
const own = getDict(locale).ui[ns] ?? {};
return { ...en, ...own };
}
This means a new locale ships immediately with English fallbacks and gets polished over time.
RTL Support
Arabic runs RTL. Every page reads dir from the locale config. CSS logical properties (margin-inline-start instead of margin-left) handle most layout flipping. The few places that need explicit RTL overrides are scoped to [dir="rtl"].
Vercel Deploy
We deploy with vercel --prod. The build outputs static HTML into .vercel/output/static/. With 5,000+ files, build times stay under two minutes because there is no SSR and no serverless functions. The sitemap generator runs at build time and includes every locale variant with xhtml:link rel="alternate" for hreflang.
What We Learned
- Ship incomplete translations early with a fallback chain. Waiting for 100% coverage before launch is a trap.
- Use TypeScript for translation files so missing keys are caught at build time.
- Static generation at this scale is fast if you avoid SSR. Our full build plus deploy takes under three minutes.
Operated by Serenity Morocco Tours. Visit navetteforyou.com or WhatsApp +212 701 664 704.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.