perf: apply Vercel React best practices (async-parallel and server-serialization)

This commit is contained in:
AyrisAI
2026-05-16 01:17:45 +03:00
parent 15fee9be38
commit 782e11f795
2 changed files with 12 additions and 8 deletions

View File

@@ -37,18 +37,21 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
export default async function ServiceLocationPage({ params }: Props) { export default async function ServiceLocationPage({ params }: Props) {
const { slug, location: locationSlug } = await params; const { slug, location: locationSlug } = await params;
const [service, location, settings] = await Promise.all([
getServiceBySlug(slug), // Vercel Best Practice: async-parallel - Fetch independent operations in parallel
const service = await getServiceBySlug(slug);
if (!service) notFound();
const [location, settings, projects] = await Promise.all([
getLocationBySlug(locationSlug), getLocationBySlug(locationSlug),
getSettings() getSettings(),
getProjectsByService(service.title)
]); ]);
if (!service || !location) { if (!location) {
notFound(); notFound();
} }
const projects = await getProjectsByService(service.title);
const breadcrumbLd = { const breadcrumbLd = {
"@context": "https://schema.org", "@context": "https://schema.org",
"@type": "BreadcrumbList", "@type": "BreadcrumbList",

View File

@@ -19,8 +19,9 @@ export async function generateMetadata(): Promise<Metadata> {
export default async function ServicesPage() { export default async function ServicesPage() {
const [services, locations] = await Promise.all([ const [services, locations] = await Promise.all([
sql`SELECT * FROM services ORDER BY display_order ASC`, // Vercel Best Practice: server-serialization - Select only required fields
sql`SELECT * FROM locations ORDER BY display_order ASC` sql`SELECT id, title, description, slug, icon_name, sub_services FROM services ORDER BY display_order ASC`,
sql`SELECT id, name, slug FROM locations ORDER BY display_order ASC`
]); ]);
const servicesSchema = { const servicesSchema = {