You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
but this doesn't work the same as ssr: false
in ssr: false, initial data fetching happens on the client
with clientOnly data is initially brought by the server
If you want to fetch data on the client, use a simple fetch inside the onMount hook. If you want to fetch data on the server, use SolidJS’s createResource hook. Another solution is to create an API endpoint and fetch from it on the client.
If you want to fetch data on the client, use a simple fetch inside the onMount hook. If you want to fetch data on the server, use SolidJS’s createResource hook. Another solution is to create an API endpoint and fetch from it on the client.
Your approach is sound, but I have encountered some issues. For instance, when attempting to use Axios for network requests and needing to retrieve a JWT from localStorage to configure an Axios interceptor, I receive the error “localStorage is not undefined”.
The server renders only the fallback and runs no queries. The page's createAsync/query calls run on the client after it mounts, the same as ssr: false. If the route has a preload, the server runs it and sends the data along, which is the behavior described above.
Browser-only code such as localStorage access, or an Axios interceptor that reads it, should live in the module clientOnly imports, not in the route file. The server still loads the route file.
For an app-wide version without hydration that still sends the page's data, see ssr: "data-only" in #2352 (2.x) and #2353 (1.x).
Activity
hytkhn01 commentedon Aug 10, 2025
If you want to fetch data on the client, use a simple fetch inside the onMount hook. If you want to fetch data on the server, use SolidJS’s createResource hook. Another solution is to create an API endpoint and fetch from it on the client.
SillyFunc commentedon Oct 11, 2025
Your approach is sound, but I have encountered some issues. For instance, when attempting to use Axios for network requests and needing to retrieve a JWT from localStorage to configure an Axios interceptor, I receive the error “localStorage is not undefined”.
lxsmnsyc commentedon Oct 14, 2026
This works today on 1.x and 2.x by loading the page through
clientOnlyand leaving out a routepreload:The server renders only the fallback and runs no queries. The page's
createAsync/querycalls run on the client after it mounts, the same asssr: false. If the route has apreload, the server runs it and sends the data along, which is the behavior described above.Browser-only code such as
localStorageaccess, or an Axios interceptor that reads it, should live in the moduleclientOnlyimports, not in the route file. The server still loads the route file.For an app-wide version without hydration that still sends the page's data, see
ssr: "data-only"in #2352 (2.x) and #2353 (1.x).