tkirishima
tkirishima
SSolidJS
Created by tkirishima on 7/11/2023 in #support
SSR and routes in Solid.JS
Well, it works in JavaScript. But in TypeScript it's another story. If you do
npx degit solidjs/templates/ts my-app
cd my-app
npm install # or yarn or pnpm
npm run dev # or yarn or pnpm
npx degit solidjs/templates/ts my-app
cd my-app
npm install # or yarn or pnpm
npm run dev # or yarn or pnpm
And after that, try to create a server.tsx with something like:
import express from "express";
import { renderToString } from "solid-js/web";

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

const app = express();

app.get("/", (req: any, res: any) => {
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: any, res: any) => {
const html = renderToString(() => <App />);
res.send(html);
});
app.listen(3000, () => {
console.log("Server started on port 3000");
});
And try to run the server with ts-node src/server.tsx you fall in a rabbit hole of errors. Like Unknown file extension ".tsx", and after that, you try to remove "type": "module", in package.json, but new errors are coming. It would be great to have a default template for SSR in typescript that actually work out of the box.
10 replies
SSolidJS
Created by tkirishima on 7/11/2023 in #support
SSR and routes in Solid.JS
Well, solidStart is in beta. And in solid start there are a lot of stuff that I dont need.
10 replies
SSolidJS
Created by tkirishima on 7/11/2023 in #support
SSR and routes in Solid.JS
So there isn't any way to do that in Solid.JS ?
10 replies
SSolidJS
Created by tkirishima on 3/19/2023 in #support
Routes and FileRoutes
But if I create different folder for them, the URL to access them is also going to change, no ?
8 replies
SSolidJS
Created by tkirishima on 3/19/2023 in #support
Routes and FileRoutes
(And a,b,c,d,e,f are in the same folder)
8 replies
SSolidJS
Created by tkirishima on 3/19/2023 in #support
Routes and FileRoutes
Thanks :) Helped me! But from what I understood, it doesn't totally respond to my problem. For example, if I have 6 files a.tsx, b.tsx, c.tsx, d.tsx, e.tsx, f.tsx and that I would like to have a specific header for a,b,c and another one for d, e, f would it be possible ?
8 replies