SolidJS: React Flavored Pre-rendered Components
SolidJS is a framework that tries to create a simpler and faster environment by combining the best features from React and Svelte.
SolidJS is one of those frameworks that tries to modernize and simply React style development by relying on components that are then rendered in a way that's similar to Svelte.
That delivers faster applications with components that are familiar to write, but have some improvements over React.
It's main focus is on delivering more performant applications and uses Vite for it's build process, so it has a lot of modern features like hydration, suspense, streaming and more.
Let's take a look at how you'd build a simple app with it.
It doesn't have a build tool, so you install this with degit like you do with svelte.
npx degit solidjs/templates/js demo-solid cd demo-solid npm i code ./ npm run dev
There's a few package.json files and this pnpm lock file. I use npm, so this isn't really
You get a Vite config file. Vite has really taken over the build processes of almost all modern frameworks. That's pretty impressive
You can see the index file here, which has no imports except for the index.jsx file.
Remember that Solid is going to use Vite to process things for you, so this file will be managed by your setup.
Notice the div with the ID or root. That's where your app goes.
The whole app is in the src folder.
Assets is where your publicly available files are.
Lets look at the index.jsx, which is your extry point. Notice that it does work with the JSX format, but since it's going to be processed, there are some improvements.
It's importing the library's render method and also the CSS...this would be your global CSS.
It's also importing App.js. This is your main component where the rest of the app is placed.
The render function looks for a root element in the index.html file.
In the App.jsx, you have two imports. One for the SVG. notice that it goes into a variable as well as the styles from the module.css. If you're not used to this, it's CSS in jS where the CSS classes will be available to your project as an object.
Notice the class calls here reference that object and then the class name.
The image call also references our SVG. This is part of how Vite works and a lot of other frameworks are using this as well.
Just in case you didn't notice, although this is JSX, you get to use class instead of className like you would do in react. However, there must still be a single component. So the DIV here is acting as that component.
Alright, let's get down to what's different.