<head>
public/
.server.js
.client.js
.shared.js
pageContext
Page
route
Head
Layout
+client.js
data()
guard()
onBeforeRender()
onHydrationEnd()
onPageTransitionStart()
onPageTransitionEnd()
onBeforePrerenderStart()
onPrerenderStart()
useData()
usePageContext()
useConfig()
throw redirect()
throw render()
clientOnly()
modifyUrl()
navigate()
reload()
prefetch()
renderPage()
escapeInject
injectFilter()
prerender()
title
description
image
viewport
htmlAttributes
bodyAttributes
ssr
stream
prerender
redirects
keepScrollPosition
prefetchStaticAssets
hooksTimeout
passToClient
clientRouting
meta
For simple apps, you can define a basic file structure with a single pages/ directory.
pages/
For advanced apps, you may want to define several pages/ directories for what we call a domain-driven file structure.
# Landing page /pages/index/+Page.js /pages/index/components/SomeComponentForLandingPage.js /pages/index/**/* # More files specific to the landing page # About page /pages/about/+Page.js /pages/about/components/SomeComponentForAboutPage.js /pages/about/**/* # More files specific to the about page # Other pages /pages/**/+Page.js # Error page /pages/_error/+Page.js # Components shared by several pages /components/ # Server code (Express.js/Fastify/...) /server/
# =========================== # ======= Marketing ========= # =========================== # Pages (marketing)/pages/index/+Page.js # URL: / (marketing)/pages/about/+Page.js # URL: /about # Configs (marketing)/pages/+Layout.js (marketing)/pages/+prerender.js # Components (marketing)/components/ContactUs.js # =========================== # ===== Authentication ====== # =========================== # Pages auth/pages/signup/+Page.js # URL: /auth/signup auth/pages/login/+Page.js # URL: /auth/login # Configs auth/pages/+Layout.js # Components auth/components/UserInfo.js # Database auth/database/fetchUser.js # =========================== # ===== Product pages ======= # =========================== # Pages products/pages/index/+Page.js # URL: /products products/pages/product/+Page.js # URL: /product/@id products/pages/product/+route.js # Configs products/pages/+Layout.js products/pages/+ssr.js # Database products/database/fetchProduct.js products/database/fetchProductList.js # ============================= # ======= Shared/Misc ========= # ============================= # Components shared across all domains components/ # Server code server/
// /products/pages/product/+route.js export default '/product/@id'