Connection to SvelteKit
SvelteKit adds routes, data loading and server rendering. The @woodger/antd components are imported from the same package found in the Vite application.
Preparation of the project
Create an application with the official CLI, select the appropriate template and TypeScript:
npx sv create my-app
cd my-app
npm install @woodger/antd
For an existing application, run the install command from its root directory. Installing the package
General Layout
Place ConfigProvider in src/routes/+layout.svelte. It will pass settings to the pages and include the package's CSS.
<script lang="ts">
import type { LayoutProps } from './$types';
import { ConfigProvider, ruRU } from '@woodger/antd';
let { children }: LayoutProps = $props();
</script>
<ConfigProvider locale={ruRU}>
{@render children()}
</ConfigProvider>
Types ./$types is created by SvelteKit. For child sections, you can add a nested layout with its own ConfigProvider. Theme and component config inheritance rules are different; they are described in topics.
Vite config SvelteKit uses sveltekit() from @sveltejs/kit/vite. Don't replace it with regular svelte() for the sake of the library. No additional React configuration is required.
Application page
Save the source first example as src/lib/FirstExample.svelte and connect it to src/routes/+page.svelte:
<script lang="ts">
import FirstExample from '$lib/FirstExample.svelte';
</script>
<FirstExample />
The example has its own ConfigProvider. It inherits the settings of the external provider; After transferring it to the application, you can leave it for local settings or remove it, saving the general provider in the layout.
createForm field and model values in a page or editor component instance. For a new editable object, explicitly determine whether you want to save the draft or create a new model. Changing the route does not always recreate the page component.
Server and browser data
Load loads the data and the component creates an edit state. Do not return theme algorithm functions, handlers, or FormInstance from server load. For the theme, pass the string mode, for Day.js - a date string or timestamp, then create an instance of Dayjs in the UI.
Form can store Dayjs directly. Convert for a server action or request to be done at the send boundary, with explicit decisions about format and time zone. DatePicker explains the meaning model.
Rules for the same initial markup and an example cookie theme are given in SSR.
Review and publication
Start the dev server, perform type checking from the scripts of your project, then build and preview. Open the page directly and after following the internal link; check the input, popup and absence of hydration errors.
To publish, select adapter for the target environment. The library does not require a specific adapter and disabling SSR. npm run preview is intended for local verification; The web server settings and application hosting are owned by the consumer project.