Auth
Edit this pageServer functions can be used to protect sensitive resources like user data.
The getUser
function can be implemented using sessions.
Protected Routes
Routes can be protected by checking the user or session object during data fetching. This example uses Solid Router.
Once the user hits this route, the router will attempt to fetch getPrivatePosts
data.
If the user is not signed in, getPrivatePosts
will throw and the router will redirect to the login page.