Replies: 2 comments
-
I didn't require client-only to solve this issue. A bit of script early on in header to set the class solved the problem (browser's run javascript before the first page render even if the page is all server-side). At some point SSR per route will probably come up though. |
Beta Was this translation helpful? Give feedback.
0 replies
-
In ... and come up with an example of how a route may be rendered without SSR (assuming noSSR means what I think it does). This is not tested, I'm just entertaining an idea.. import Root from "solid-start/start/root";
// function
return (
<>
<ServerContext.Provider value={event}>
<!DOCTYPE html>
<Root />
</ServerContext.Provider>
</>
) //[solid-start] StartServer.tsx
const devNoSSR = import.meta.env.DEV && !import.meta.env.START_SSR;
const docType = ssr("<!DOCTYPE html>");
export default function StartServer({ event }: { event: PageEvent }) {
const parsed = new URL(event.request.url);
const path = parsed.pathname + parsed.search;
// @ts-ignore
sharedConfig.context.requestContext = event;
return (
<ServerContext.Provider value={event}>
{devNoSSR ? (
<>
{docType as unknown as any}
<Root />
</>
) : (
<MetaProvider tags={event.tags as ComponentProps<typeof MetaProvider>["tags"]}>
<StartRouter
url={path}
out={event.routerContext}
location={path}
prevLocation={event.prevUrl}
data={dataFn}
routes={fileRoutes}
>
{docType as unknown as any}
<Root />
</StartRouter>
</MetaProvider>
)}
</ServerContext.Provider>
);
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Any ideas about how to render a page (route) on the client side only? This is for light / dark mode where the default is a browser media query or a user setting saved and known only on the client side. So, this 1st page should be client side only while solid start has SSR enabled.
Nuxt has Hybrid Rendering where you might set
routeRules: {'/': { ssr: false }}
, and this leaves room for other configuration and features. However, that may be limiting because it seams to rely on the framework to provide specific features; it may be better to use some sort of middleware and an API where the developer can interact with solid and the request very early on and perhaps pull in other libraries.Beta Was this translation helpful? Give feedback.
All reactions