S
SolidJS•14mo ago
Carere

How to use SolidStart on existing SolidJs project in order to benefit of File Based Routing ?

PS: I use SolidJs only for SPA, so only client-side ? Is it possible to use SolidStart only for client Side ? My goal is to benefit from the organization of SolidStart, i'm used to SolidJs router on client side, but I think it's a little bit messy, so that's why I would like to try SolidStart for Client SIde only rendering (SPA)
9 Replies
mdynnl
mdynnl•14mo ago
yes, solid-start-static can be used for this disable ssr to make it behave like a SPA. if you need to render some pages as static, you can use ssr and (seems unsupported atm) you can wrap the client parts with ClientOnly helper which is just
function ClientOnly(props) {
const [mounted, setMounted] = createSignal(false)
onMount(() => setMounted(true))
return <Show when={mounted}>{props.children}</Show>
}
function ClientOnly(props) {
const [mounted, setMounted] = createSignal(false)
onMount(() => setMounted(true))
return <Show when={mounted}>{props.children}</Show>
}
Carere
Carere•14mo ago
I don't need SSR, it's a pure SPA So no need for ClientOnly ? And do I need the entry-server.tsx file since I do not use SSR ? Can I delete it ??
mdynnl
mdynnl•14mo ago
i've updated my reply, ssr: false isn't supported for static adapter but default adapter (solid-start-node) can be compiled with ssr: false which spits out both client + server, but serving the client build should work i think
Carere
Carere•14mo ago
oh ok, so i still need entry-server.tsx
mdynnl
mdynnl•14mo ago
i think you can delete both entry files but you could confirm by yourself to be sure 😆 they are mostly there so you could put up some environment specific logic
Carere
Carere•14mo ago
yes, I'm testing, and I'll provide you some feedback 😉
mdynnl
mdynnl•14mo ago
i don't think the build supports full SPA mode though so you'll have to import some client side only stuff with dynamic import especially if the stuff have some side effect code that does some client side things when imported
Carere
Carere•14mo ago
@mdynnl I got Solid Start working with the node adapter and SSR to false, I don't need any entry-* file indeed, and it works great 🙂 thx for your help 😉 Oh and if you have any idea why I can't use script in the head tag, I'll be very happy to get an answer 😅 https://discord.com/channels/722131463138705510/1137902556912296056
mdynnl
mdynnl•14mo ago
cool
Want results from more Discord servers?
Add your server