Gathering detailed insights and metrics for solid-js
NPM registry records approximately 1.5 to 2 billion package downloads per day.
Gathering detailed insights and metrics for solid-js
NPM registry records approximately 1.5 to 2 billion package downloads per day.
npm install solid-js
99
Supply Chain
100
Quality
91.3
Maintenance
100
Vulnerability
v1.9.0 - LGTM!
Published on 24 Sept 2024
v1.8.0 - Bifröst
Published on 09 Oct 2023
v1.7.0 - U Can't Type This
Published on 30 Mar 2023
v1.6.0 - Castle in the Sky
Published on 20 Oct 2022
v1.5.0 - Batch to the Future
Published on 26 Aug 2022
v1.4.0 - Level Up!
Published on 12 May 2022
32,433 Stars
1,803 Commits
926 Forks
211 Watching
5 Branches
170 Contributors
Updated on 14 Nov 2024
Minified
Minified + Gzipped
TypeScript (71.69%)
JavaScript (28.09%)
CSS (0.21%)
Cumulative downloads
Total Downloads
Last day
-1.2%
43,233
Compared to previous day
Last week
-0.3%
237,553
Compared to previous week
Last month
-2.2%
1,070,061
Compared to previous month
Last year
178.8%
13,599,340
Compared to previous year
3
Website • API Docs • Features Tutorial • Playground • Discord
Solid is a declarative JavaScript library for creating user interfaces. Instead of using a Virtual DOM, it compiles its templates to real DOM nodes and updates them with fine-grained reactions. Declare your state and use it throughout your app, and when a piece of state changes, only the code that depends on it will rerun.
1import { createSignal } from "solid-js"; 2import { render } from "solid-js/web"; 3 4function Counter() { 5 const [count, setCount] = createSignal(0); 6 const doubleCount = () => count() * 2; 7 8 console.log("The body of the function runs once..."); 9 10 return ( 11 <> 12 <button onClick={() => setCount(c => c + 1)}> 13 {doubleCount()} 14 </button> 15 </> 16 ); 17} 18 19render(Counter, document.getElementById("app")!);
Try this code in our playground!
1import { createSignal } from "solid-js"; 2import { render } from "solid-js/web"; 3 4// A component is just a function that returns a DOM node 5function Counter() { 6 // Create a piece of reactive state, giving us a accessor, count(), and a setter, setCount() 7 const [count, setCount] = createSignal(0); 8 9 //To create derived state, just wrap an expression in a function 10 const doubleCount = () => count() * 2; 11 12 console.log("The body of the function runs once..."); 13 14 // JSX allows you to write HTML within your JavaScript function and include dynamic expressions using the { } syntax 15 // The only part of this that will ever rerender is the doubleCount() text. 16 return ( 17 <> 18 <button onClick={() => setCount(c => c + 1)}> 19 Increment: {doubleCount()} 20 </button> 21 </> 22 ); 23} 24 25// The render function mounts a component onto your page 26render(Counter, document.getElementById("app")!);
Solid compiles your JSX down to efficient real DOM updates. It uses the same reactive primitives (createSignal
) at runtime but making sure there's as little rerendering as possible. Here's what that looks like in this example:
1import { template as _$template } from "solid-js/web"; 2import { delegateEvents as _$delegateEvents } from "solid-js/web"; 3import { insert as _$insert } from "solid-js/web"; 4//The compiler pulls out any static HTML 5const _tmpl$ = /*#__PURE__*/_$template(`<button>Increment: `); 6 7import { createSignal, createEffect } from "solid-js"; 8import { render } from "solid-js/web"; 9 10function Counter() { 11 const [count, setCount] = createSignal(0); 12 13 const doubleCount = () => count() * 2; 14 15 console.log("The body of the function runs once..."); 16 17 return (() => { 18 //_el$ is a real DOM node! 19 const _el$ = _tmpl$(); 20 _el$.$$click = () => setCount(c => c + 1); 21 //This inserts the count as a child of the button in a way that allows count to update without rerendering the whole button 22 _$insert(_el$, doubleCount); 23 return _el$; 24 })(); 25} 26render(Counter, document.getElementById("app")); 27_$delegateEvents(["click"]);
<div>
is a real div, so you can use your browser's devtools to inspect the renderingYou can get started with a simple app by running the following in your terminal:
1> npx degit solidjs/templates/js my-app 2> cd my-app 3> npm i # or yarn or pnpm 4> npm run dev # or yarn or pnpm
Or for TypeScript:
1> npx degit solidjs/templates/ts my-app 2> cd my-app 3> npm i # or yarn or pnpm 4> npm run dev # or yarn or pnpm
This will create a minimal, client-rendered application powered by Vite.
Or you can install the dependencies in your own setup. To use Solid with JSX (recommended), run:
1> npm i -D babel-preset-solid 2> npm i solid-js
The easiest way to get set up is to add babel-preset-solid
to your .babelrc
, babel config for webpack, or rollup configuration:
1"presets": ["solid"]
For TypeScript to work, remember to set your .tsconfig
to handle Solid's JSX:
1"compilerOptions": { 2 "jsx": "preserve", 3 "jsxImportSource": "solid-js", 4}
Meticulously engineered for performance and with half a decade of research behind it, Solid's performance is almost indistinguishable from optimized vanilla JavaScript (See Solid on the JS Framework Benchmark). Solid is small and completely tree-shakable, and fast when rendering on the server, too. Whether you're writing a fully client-rendered SPA or a server-rendered app, your users see it faster than ever. (Read more about Solid's performance from the library's creator.)
Solid is fully-featured with everything you can expect from a modern framework. Performant state management is built-in with Context and Stores: you don't have to reach for a third party library to manage global state (if you don't want to). With Resources, you can use data loaded from the server like any other piece of state and build a responsive UI for it thanks to Suspense and concurrent rendering. And when you're ready to move to the server, Solid has full SSR and serverless support, with streaming and progressive hydration to get to interactive as quickly as possible. (Check out our full interactive features walkthrough.)
Do more with less: use simple, composable primitives without hidden rules and gotchas. In Solid, components are just functions - rendering is determined purely by how your state is used - so you're free to organize your code how you like and you don't have to learn a new rendering system. Solid encourages patterns like declarative code and read-write segregation that help keep your project maintainable, but isn't opinionated enough to get in your way.
Solid is built on established tools like JSX and TypeScript and integrates with the Vite ecosystem. Solid's bare-metal, minimal abstractions give you direct access to the DOM, making it easy to use your favorite native JavaScript libraries like D3. And the Solid ecosystem is growing fast, with custom primitives, component libraries, and build-time utilities that let you write Solid code in new ways.
Check out our official documentation or browse some examples
SolidJS Core is committed to supporting the last 2 years of modern browsers including Firefox, Safari, Chrome and Edge (for desktop and mobile devices). We do not support IE or similar sunset browsers. For server environments, we support Node LTS and the latest Deno and Cloudflare Worker runtimes.
Come chat with us on Discord! Solid's creator and the rest of the core team are active there, and we're always looking for contributions.
Support us with a donation and help us continue our activities. [Contribute]
Become a sponsor and get your logo on our README on GitHub with a link to your site. [Become a sponsor]
No vulnerabilities found.
Reason
30 commit(s) and 15 issue activity found in the last 90 days -- score normalized to 10
Reason
license file detected
Details
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
security policy file detected
Details
Reason
3 existing vulnerabilities detected
Details
Reason
Found 12/26 approved changesets -- score normalized to 4
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-04
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More@tanstack/virtual-core
Headless UI for virtualizing scrollable elements in TS/JS + Frameworks
@tanstack/table-core
Headless UI for building powerful tables & datagrids for TS/JS.
vite-plugin-solid
solid-js integration plugin for vite 3/4/5
@astrojs/solid-js
Use Solid components within Astro