@stone-js/use-react 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +96 -0
- package/dist/index.d.ts +1566 -0
- package/dist/index.js +1859 -0
- package/package.json +98 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Stone.js
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Stone.js - Use React
|
|
2
|
+
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
[](https://www.npmjs.com/package/@stone-js/use-react)
|
|
5
|
+
[](https://www.npmjs.com/package/@stone-js/use-react)
|
|
6
|
+

|
|
7
|
+
[](https://github.com/stone-foundation/stone-js-use-react/actions/workflows/main.yml)
|
|
8
|
+
[](https://github.com/stone-foundation/stone-js-use-react/actions/workflows/release.yml)
|
|
9
|
+
[](https://sonarcloud.io/summary/new_code?id=stone-foundation_stone-js-use-react)
|
|
10
|
+
[](https://sonarcloud.io/summary/new_code?id=stone-foundation_stone-js-use-react)
|
|
11
|
+
[](./SECURITY.md)
|
|
12
|
+
[](https://github.com/stone-foundation/stone-js-use-react/security/code-scanning)
|
|
13
|
+
[](https://github.com/stone-foundation/stone-js-use-react/network/updates)
|
|
14
|
+
[](https://conventionalcommits.org)
|
|
15
|
+
|
|
16
|
+
React integration for [Stone.js](https://stonejs.dev), universal rendering, SSR hydration, layouts, pages, snapshots, head management, and more.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Overview
|
|
21
|
+
|
|
22
|
+
**`@stone-js/use-react`** connects the Stone.js Continuum Architecture to the React ecosystem.
|
|
23
|
+
|
|
24
|
+
It provides:
|
|
25
|
+
|
|
26
|
+
- Universal rendering for **SSR** and **SPA**
|
|
27
|
+
- Powerful `Page` and `Layout` components with optional decorators
|
|
28
|
+
- A smart `Snapshot` system to sync server/client state seamlessly
|
|
29
|
+
- Dynamic `<StoneLink>`, `<StoneClient>`, and `<StoneServer>` rendering
|
|
30
|
+
- Integration hooks for popular tools and design systems
|
|
31
|
+
|
|
32
|
+
Use it to build fully reactive apps that run everywhere, Node.js, the browser, or serverless platforms, without giving up fine-grained control over context and rendering strategy.
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install @stone-js/use-react
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
> [!IMPORTANT]
|
|
41
|
+
> This package is **pure ESM**. Make sure your `package.json` includes `"type": "module"` or configure your bundler accordingly.
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
This package is designed to be used inside a Stone.js app and integrates deeply with its lifecycle, adapter system, and blueprint configuration.
|
|
46
|
+
|
|
47
|
+
You can define Pages and Layouts:
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { Page } from '@stone-js/use-react'
|
|
51
|
+
|
|
52
|
+
@Page('/about')
|
|
53
|
+
export class AboutPage {
|
|
54
|
+
render() {
|
|
55
|
+
return <div>About Stone.js</div>
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
You can hydrate data with snapshots:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { Stone } from '@stone-js/core'
|
|
64
|
+
import { Snapshot } from '@stone-js/use-react'
|
|
65
|
+
|
|
66
|
+
@Stone({ alias: 'userService' })
|
|
67
|
+
export class UserService {
|
|
68
|
+
@Snapshot()
|
|
69
|
+
showProfile() {
|
|
70
|
+
return { name: 'John Doe' }
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
You can render elements conditionally:
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
<StoneClient>Visible on client</StoneClient>
|
|
79
|
+
<StoneServer>Visible on server</StoneServer>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
And much more.
|
|
83
|
+
|
|
84
|
+
## Learn More
|
|
85
|
+
|
|
86
|
+
This package is part of the Stone.js ecosystem, a modern JavaScript framework built around the Continuum Architecture.
|
|
87
|
+
|
|
88
|
+
Explore the full documentation: https://stonejs.dev
|
|
89
|
+
|
|
90
|
+
## API documentation
|
|
91
|
+
|
|
92
|
+
* [API](https://github.com/stone-foundation/stone-js-use-react/blob/main/docs)
|
|
93
|
+
|
|
94
|
+
## Contributing
|
|
95
|
+
|
|
96
|
+
See [Contributing Guide](https://github.com/stone-foundation/stone-js-use-react/blob/main/CONTRIBUTING.md)
|