티스토리 뷰

tech/Frontend

Svelte 개발하기, Routing

drillandrill 2023. 3. 18. 14:31
Svelte 개발 중 라우팅을 정리한 글

Routing

라우팅은 어떤 프론트 기술에서도 동일하게 적용되는 개념이니 간단하게 정리하려고 한다.

스벨트키트 레퍼런스 라우팅 부분을 보면 따로 라이브러리 안 쓰고 동적 라우팅 하는 방법을 알려주고 있었다.

나는 이걸 스치듯이 보고 넘어가서 라이브러리를 사용하는 걸로 해결하려 했는데 그럴 필요가 없었음

 

Routing • Docs • SvelteKit

Routing Edit this page on GitHub At the heart of SvelteKit is a filesystem-based router. The routes of your app — i.e. the URL paths that users can access — are defined by the directories in your codebase: src/routes is the root route src/routes/about

kit.svelte.dev

At the heart of SvelteKit is a filesystem-based router. The routes of your app — i.e. the URL paths that users can access — are defined by the directories in your codebase:
src/routes is the root route
src/routes/about creates an /about route
src/routes/blog/[slug] creates a route with a parameter, slug, that can be used to load data dynamically when a user requests a page like /blog/hello-world → 여기서 알려주고 있다

Static Routing

정적라우팅은 폴더 생성 후 그 아래 있는 파일명이나 폴더명으로 직접 처리하는 방법이다.

routes 폴더 하위에 sign-in/password-initialize로 세팅했다면 host/sign-in/password-initialize로 접근할 수 있다.

 

Dynamic Routing

동적라우팅은 별도의 생성없이 사용자가 입력한 경로를 처리해 주는 방법이다.

왼쪽 이미지에 따르면 host/this-is-path 라고 입력할 때 해당 경로로 접근할 수 있다.

'tech > Frontend' 카테고리의 다른 글

CSR, SSR  (0) 2023.03.18
Svelte 이해하기(2)  (0) 2023.03.18
Svelte 이해하기  (0) 2023.03.18
ESLint, Prettier 차이점과 사용이유  (0) 2023.03.18
최근에 올라온 글
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
글 보관함