Loading in Clients
While discussing Creating Server Pages in the previous chapter, we covered how a load()
function exported from +page.js
will run on both the client and the server. When we want to ensure load is only run on the server, we move it to +page.server.js
. But what if you’re trying to build an offline-ready application? You may be building a Progressive Web App (PWA), a Single-Page App (SPA), or both! For the sake of demonstration, let’s assume you want as much logic as possible to be managed on the client rather than your server. In this case, you’ll want load()
functions to run on the client and not on the server. How can we do that when a load()
function from +page.js
runs in both environments?
Again, think back to the Creating Server Pages section in the previous chapter where we discussed page options, and you’ll remember the ssr
option. When exported, this constant will disable or enable Server-Side Rendering based on the Boolean value...