DEV/svelte
svelte 데이터 불러오기, 불러온 데이터 사용하기
석봉
2023. 11. 28. 15:49
데이터를 불러올 route에 "+page.js" 파일을 생성하고 다음과 같이 데이터를 export한다.
본인은 src/routes/sample 에서 테스트하였다.
svelte는 SSR(Sever Side Rendering) 또한 지원하기때문에 클라이언트에 노출되지 않고 사용하고 싶다면
"+page.server.js"로 파일을 생성하면 된다.
DB접근이나 API키 사용 등 필요에 따라 사용하면 된다.
ref)
https://kit.svelte.dev/docs/routing
Routing • Docs • SvelteKit
Routing Edit this page on GitHub On this page On this page 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 ro
kit.svelte.dev