[Feature?]: disable ssr for some pages
Duplicates
- [x] I have searched the existing issues
Latest version
- [x] I have tested the latest version
Summary 💡
currently we can do this:
function Home() {
return <h1>Home</h1>;
}
import { clientOnly } from "@solidjs/start";
export default clientOnly(() => Promise.resolve({ default: Home }));
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
Examples 🌈
No response
Motivation 🔦
No response
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”.