Help me with my workflow and dependencies? #73
-
Hello! I was hoping you could give me some advice on how to get started. You see, I have a nodejs Express server, which usually is used to run api calls. But occasionally, I send some raw html. Typically something like: let html = `
<html>
<h2>Welcome</h2>
<input id="input" />
<button onclick="let input = document.getElementById('input');fetch('website/api/signup', {....">
Sign Up
</button>
</html>`
res.send(html); It's pretty bad, and I'm used to using react. But I also am running my server on a low capacity computer and don't want to use a bunch of resources either building, or having a lot of dependencies. I would really like to work with JSX. Escaping strings is a nightmare. Anyways, I've tried your SSR example, but I don't want to use typescript, so I was running it for testing like Do you have any ideas on how to minimize the number of dependencies and work my computer has to do to just generate some simple reactive html that is in JSX format? I've tried |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
To run Nano JSX with SSR you only need a few packages. Have a look at the example1 package.json. This is the minimal setup. Actually you can even reduce the size of your bundle.js when you import only single components like: import * as Nano from 'nano-jsx/lib/core'
import { Component } from 'nano-jsx/lib/component'
import { Helmet } from 'nano-jsx/lib/components/helmet'
import * as Router from 'nano-jsx/lib/components/router' Besides I recommend using the tsconfig.json settings from the template. I also come from react and I just can recommend dropping the usage completly. The usage of Nano JSX compared to react is almost the same and within some days you can learn how to use all components. As far as I can see in your code has some errors, since you assign your html code to the |
Beta Was this translation helpful? Give feedback.
-
I just made a simple example for you. |
Beta Was this translation helpful? Give feedback.
-
Thank you two! I've integrated some the new @jrson83 Yep, that example code was a quick writeup of what I was basically doing. It wasn't actual code from my project (code is abstracted a bit more) hence why I was sending I'll comment again when I get things working on the pi how I intend it to, just as an update. Probably be a few days before I can get back to messing with it. Ttyl! |
Beta Was this translation helpful? Give feedback.
I just made a simple example for you.
See: https://github.com/nanojsx/node-jsx-example.