Publish to my blog (weekly)
-
- throw
Error): HttpError (+1 overload) import error">error (404, {Error.message: string">message : 'Not found'});
-
-
- making them useful for initializing database clients and so on.
- This function runs every time the SvelteKit server receives a request — whether that happens while the app is running, or during prerendering — and determines the response.
-
HandleServerError import HandleServerError">HandleServerError -
HandleClientError import HandleClientError">HandleClientError
-
-
Advanced routing • Docs • SvelteKit
- unlike normal directories,
(app)
and(marketing)
do not affect the URL pathname of the routes inside them:
-
-
Form actions • Docs • SvelteKit
- ?/registe
- /login?/register
- action="?/login"
- <button formaction="?/register">Register</button
-
RequestEvent<{}, string | null>) => Promise<{ success: boolean; }>">login : async ({Cookies">cookies ,request }) => { -
RequestEvent<{}, string | null>) => Promise<void>">register : async (RequestEvent<{}, string | null>">event ) => { - This means that your page's
load
functions will run after the action completes. - Note that
handle
runs before the action is invoked, and does not re-run before theload
functions.
-
-
Page options • Docs • SvelteKit
- To define an option for the whole app, export it from the root layout.
- you always include a file extension
-
src/routes/foo.json/+server.js
andsrc/routes/foo/bar.json/+server.js
-
-
Loading data • Docs • SvelteKit
- If your
load
function should always run on the server (because it uses private environment variables, for example, or accesses a database) then you can put it in a+page.server.js
instead. - shared
- server-only
-
-
- a filesystem-based router
- which can be identified by their
+
prefix. - A
+page.svelte
component defines a page of your app - a href="/about">About my site</a>
- <a href="/">Home</a>
- Often, a page will need to load some data before it can be rendered.
- export const
load :Load<{ slug: string; }, Record<string, any> | null, Record<string, any>, void | Record<string, any>, string | null> import PageLoad">PageLoad -
params .slug - return {
title : 'Hello world!',content : 'Welcome to our blog. Lorem ipsum dolor sit amet...'};
-
-
- If your effect returns a function, React will run it when it is time to clean up:
-
댓글