# @storeon/solidjs

> A tiny connector for Storeon and Solid.js

Latest version **3.0.1** (published 2021-10-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @storeon/solidjs
pnpm add @storeon/solidjs
yarn add @storeon/solidjs
bun add @storeon/solidjs
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2021-10-25 |
| First published | 2020-05-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | ^12.0.0 \|\| ^14.0.0 \|\| >=16.0.0 |
| Dependencies | 0 |
| Unpacked size | 7.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 41 |
| Author | Dmytro Mostovyi |
| Maintainers | distolma, ai |
| Keywords | storeon, state, solid-js, solid |

## Links

- npm: https://www.npmjs.com/package/@storeon/solidjs
- Repository: git@github.com:storeon/solidjs
- npm.io page: https://npm.io/package/@storeon/solidjs

## Alternatives

- [@reckona/mreact-store](https://npm.io/package/@reckona/mreact-store.md) — 976 weekly downloads
- [regular-state](https://npm.io/package/regular-state.md) — 410 weekly downloads
- [@pacote/flux-actions](https://npm.io/package/@pacote/flux-actions.md) — 65 weekly downloads
- [@pilotlab/lux-debug](https://npm.io/package/@pilotlab/lux-debug.md) — 39 weekly downloads
- [vue-persist-state](https://npm.io/package/vue-persist-state.md) — 19 weekly downloads

## Recent versions

- 3.0.1 (latest) — 2021-10-25
- 3.0.0 — 2021-10-25
- 2.0.0 — 2021-03-05
- 1.0.0 — 2020-06-21
- 0.1.0 — 2020-05-05

## README

# Storeon Solid.js

[![npm version](https://badge.fury.io/js/%40storeon%2Fsolidjs.svg)](https://www.npmjs.com/package/@storeon/solidjs)
[![Build Status](https://travis-ci.org/storeon/solidjs.svg?branch=master)](https://travis-ci.org/storeon/solidjs)

<img src="https://storeon.github.io/storeon/logo.svg" align="right" alt="Storeon logo by Anton Lovchikov" width="160" height="142">

[Solid.js] a declarative, efficient, and flexible JavaScript library for building user interfaces. `@storeon/solidjs` package helps to connect store with Solid.js to provide a better performance and developer experience while remaining so tiny.

- **Size**. 200 bytes (+ Storeon itself) instead of ~3kB of Redux (minified and gzipped).
- **Ecosystem**. Many additional [tools] can be combined with a store.
- **Speed**. It tracks what parts of state were changed and re-renders only components based on the changes.

[storeon]: https://github.com/storeon/storeon
[tools]: https://github.com/storeon/storeon#tools
[solid.js]: https://github.com/ryansolid/solid
[size limit]: https://github.com/ai/size-limit
[article]: https://evilmartians.com/chronicles/storeon-redux-in-173-bytes

## Install
```sh
npm install -S @storeon/solidjs
```
or
```sh
yarn add @storeon/solidjs
```
## How to use

Create store using `storeon` module:

#### `store.js`

```javascript
import { createStoreon } from 'storeon'

let counter = store => {
  store.on('@init', () => ({ count: 0 }))
  store.on('inc', ({ count }) => ({ count: count + 1 }))
}

export const store = createStoreon([counter])
```

#### `main.js`

Provide store using `StoreonProvider` from `@storeon/solidjs`:

```js
import { render } from 'solid-js/dom'
import { StoreonProvider } from '@storeon/solidjs'
import { store } from './store'

render(
  <StoreonProvider store={store}>
    <App />
  </StoreonProvider>,
  document.body
)
```

Import `useStoreon` decorator from `@storeon/solidjs`:

#### `Counter.jsx`

```js
import { useStoreon } from '@storeon/solidjs'

export default function Counter() {
  const [state, dispatch] = useStoreon()

  return (
    <div>
      {state.count}
      <button onClick={() => dispatch('inc')}>inc</button>
    </div>
  )
}
```

## Using with TypeScript

#### `Counter.tsx`

```js
import { useStoreon } from '@storeon/solidjs'
import { State, Events } from './store'

export default function Counter() {
  const [state, dispatch] = useStoreon<State, Events>()

  return (
    <div>
      {state.count}
      <button onClick={() => dispatch('inc')}>inc</button>
    </div>
  )
}
```

---
_Source: https://npm.io/package/@storeon/solidjs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
