tkirishima
tkirishima
SSolidJS
Created by tkirishima on 7/11/2023 in #support
SSR and routes in Solid.JS
On the Solid.JS website, it is stated that it supports server-side rendering (SSR). However, I am unable to find a straightforward method for SSR with routing. For instance, if I consider the following example:
import express from "express";
import { renderToString } from "solid-js/web";

function App() {
return <h1>Hello World</h1>;
}

const app = express();

app.get("/", (req, res) => {
const html = renderToString(() => <App />);
res.send(html);
});

app.listen(3000, () => {
console.log("Server started on port 3000");
});
import express from "express";
import { renderToString } from "solid-js/web";

function App() {
return <h1>Hello World</h1>;
}

const app = express();

app.get("/", (req, res) => {
const html = renderToString(() => <App />);
res.send(html);
});

app.listen(3000, () => {
console.log("Server started on port 3000");
});
(https://docs.solidjs.com/references/concepts/ssr/simple-client-fetching-ssr) Although this code works, it does not explain how to incorporate routing. Is there a way to make it work based on the request URL received by Express without requiring modifications to the App component?
10 replies
SSolidJS
Created by tkirishima on 3/19/2023 in #support
Routes and FileRoutes
Hello! I'm new to Solid and I had some questions about Routes. I followed what was written in solidStart, but I still have some questions about FileRoutes. For example, is it possible to create a custom Layer for some pages and still using FileRoutes ? For example, with a tree like that
routes
├── [...404].tsx
├── index.tsx
└── test.tsx
routes
├── [...404].tsx
├── index.tsx
└── test.tsx
For example, I would like for index.tsx and test.tsx to both have a <Header/> that would be defined in ~/components I know that this is possible with Routes, but I was wondering if it was with FileRoutes
8 replies