Server Routes
Server-side routes are used to link the frontend with the storage/database of the web application. Let's get an overview of the server-side routes.
We'll cover the following
There are two types of routes in Sapper: pages and server routes.
According to official documentation, “Pages are Svelte components written in .svelte
files. A user is first served a server-rendered version of the route in question and a client-side router is initialized. Afterward, navigation is entirely handled by the client.” However, in this lesson, we will focus on the functionalities of server routes.
Server routes in Sapper
A server route exports functions corresponding to HTTP methods (GET, POST, etc.) and allows us to create JSON APIs without needing to deploy a separate REST API service. Server routes require a Sapper server to run. In this course, we will focus on a static site generated by Sapper and will not use server routes.
Get hands-on with 1400+ tech skills courses.