Skip to content

What's the difference between server-side and client-side load function? & Purpose of $lib/server/* #13087

Answered by brunnerh
The-LukeZ asked this question in Q&A
Discussion options

You must be logged in to vote

I know that there is a +page.server.js file which can export a load function - is that the server-side load function?

Yes.

If so, what is the purpose of the server directory in $lib ?

I am not aware of any directory within $lib having a special function. If there is such a directory, it might be just for organizational purposes (there e.g. are restrictions on access to environment variables, so splitting files between client and server can make sense).

And is the onMount function the "client-side load function"?

No. Anything in onMount is simply executed when the component mounts, this does not need to have anything to do with loading either.

There are no strictly client-side load f…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by The-LukeZ
Comment options

You must be logged in to vote
1 reply
@brunnerh
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants