description: 'Svelte Meta Tags is a Svelte component for managing meta tags and SEO in your Svelte applications.',
canonical: newURL(url.pathname, url.origin).href, // creates a cleaned up URL (without hashes or query params) from your current URL
openGraph: {
type: 'website',
url: newURL(url.pathname, url.origin).href,
locale: 'en_IE',
title: 'Open Graph Title',
description: 'Open Graph Description',
siteName: 'SiteName',
images: [
{
url: 'https://www.example.ie/og-image.jpg',
alt: 'Og Image Alt',
width: 800,
height: 600,
secureUrl: 'https://www.example.ie/og-image.jpg',
type: 'image/jpeg'
}
]
}
});
return { ...baseTags };
};
Note: defineBaseMetaTags is a utility meant to be used in a +layout.(j|t)s file.
It returns a frozen MetaTagsProps object wrapped in a baseMetaTags property for direct use in your load data.
You can also provide a raw object without this utility with return { baseMetaTags: Object.freeze<MetaTagsProps>({ ... }) }.
MetaTagsProps is a type provided by this package, imported using import type { MetaTagsProps } from 'svelte-meta-tags'.
Note: like defineBaseMetaTags, definePageMetaTags is a utility meant to be used in a +page.(j|t)s file.
It returns a frozen MetaTagsProps object wrapped in a pageMetaTags property for direct use in your load data.
You can also provide a raw object without this utility with return { pageMetaTags: Object.freeze<MetaTagsProps>({ ... }) }.
MetaTagsProps is a type provided by this package, imported using import type { MetaTagsProps } from 'svelte-meta-tags'.
SvelteKit’s remote functions allow you to define server-only functions in .remote.ts files and call them directly from components.
Note: For SEO purposes, the traditional approach using load functions (shown above) is recommended, as it guarantees meta tags are included in the server-rendered HTML. Remote functions are better suited for pages where SEO is less critical (e.g., dashboards, authenticated pages) and you want to colocate data fetching with the component.
Note: Remote functions are an experimental feature. You need to enable them in your svelte.config.js:
Note: Using await expressions requires enabling experimental.async in the Svelte compiler options. Using $derived ensures the query re-runs on client-side navigation when parameters change. A <svelte:boundary> is needed in an ancestor component to handle loading and error states.