solid-js 2.0.0-beta.8 → 2.0.0-beta.9

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/README.md CHANGED
@@ -2,222 +2,78 @@
2
2
  <img src="https://assets.solidjs.com/banner?project=Library&type=core" alt="SolidJS" />
3
3
  </p>
4
4
 
5
- [![Build Status](https://img.shields.io/github/actions/workflow/status/solidjs/solid/main-ci.yml?branch=main&logo=github&style=for-the-badge)](https://github.com/solidjs/solid/actions/workflows/main-ci.yml)
6
- [![Coverage Status](https://img.shields.io/coveralls/github/solidjs/solid.svg?style=for-the-badge)](https://coveralls.io/github/solidjs/solid?branch=main)
7
-
8
5
  [![NPM Version](https://img.shields.io/npm/v/solid-js.svg?style=for-the-badge)](https://www.npmjs.com/package/solid-js)
9
6
  [![](https://img.shields.io/npm/dm/solid-js.svg?style=for-the-badge)](https://www.npmjs.com/package/solid-js)
10
7
  [![Discord](https://img.shields.io/discord/722131463138705510?style=for-the-badge)](https://discord.com/invite/solidjs)
11
- [![Subreddit subscribers](https://img.shields.io/reddit/subreddit-subscribers/solidjs?style=for-the-badge)](https://www.reddit.com/r/solidjs/)
12
-
13
- **[Website](https://www.solidjs.com/) • [API Docs](https://docs.solidjs.com/) • [Features Tutorial](https://www.solidjs.com/tutorial/introduction_basics) • [Playground](https://playground.solidjs.com/?version=1.3.13#NobwRAdghgtgpmAXGGUCWEwBowBcCeADgsrgM4Ae2YZA9gK4BOAxiWGjIbY7gAQi9GcCABM4jXgF9eAM0a0YvADo1aAGzQiAtACsyAegDucAEYqA3EogcuPfr2ZCouOAGU0Ac2hqps+YpU6DW09CysrGXoIZlw0WgheAGEGCBdGAAoASn4rXgd4sj5gZhTcLF4yOFxkqNwAXV4AXgcnF3cvKDV0gAZMywT8iELeDEc4eFSm3iymgD4KqprU9JLamYBqXgBGPvCBoVwmBPTcvN4AHhN6XFx43gJiRpUrm-iVXnjEjWYAa0aQUZCCa4SSzU5nfirZaZSTgi76F63CBgga7CCwiBWISicTpGaNebnJZpXj6WblES0Zj0YEAOg8VQAompxsJcAAhfAASREJzAUEIhBUmTRYEkdSAA) • [Discord](https://discord.com/invite/solidjs)**
14
-
15
- 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. Check out our [intro video](https://www.youtube.com/watch?v=cELFZQAMdhQ) or read on!
16
-
17
- ## Key Features
18
-
19
- - Fine-grained updates to the real DOM
20
- - Declarative data: model your state as a system with reactive primitives
21
- - Render-once mental model: your components are regular JavaScript functions that run once to set up your view
22
- - Automatic dependency tracking: accessing your reactive state subscribes to it
23
- - [Small](https://dev.to/this-is-learning/javascript-framework-todomvc-size-comparison-504f) and [fast](https://krausest.github.io/js-framework-benchmark/current.html)
24
- - Simple: learn a few powerful concepts that can be reused, combined, and built on top of
25
- - Provides modern framework features like JSX, fragments, Context, Portals, Suspense, streaming SSR, progressive hydration, Error Boundaries and concurrent rendering.
26
- - Naturally debuggable: A `<div>` is a real div, so you can use your browser's devtools to inspect the rendering
27
- - [Web component friendly](https://github.com/solidjs/solid/tree/main/packages/solid-element#readme) and can author custom elements
28
- - Isomorphic: render your components on the client and the server
29
- - Universal: write [custom renderers](https://github.com/solidjs/solid/releases/tag/v1.2.0) to use Solid anywhere
30
- - A growing community and ecosystem with active core team support
31
-
32
- <details>
33
-
34
- <summary>Quick Start</summary>
35
-
36
- You can get started with a simple app by running the following in your terminal:
37
-
38
- ```sh
39
- > npx degit solidjs/templates/js my-app
40
- > cd my-app
41
- > npm i # or yarn or pnpm
42
- > npm run dev # or yarn or pnpm
43
- ```
44
-
45
- Or for TypeScript:
46
-
47
- ```sh
48
- > npx degit solidjs/templates/ts my-app
49
- > cd my-app
50
- > npm i # or yarn or pnpm
51
- > npm run dev # or yarn or pnpm
52
- ```
53
-
54
- This will create a minimal, client-rendered application powered by [Vite](https://vitejs.dev/).
55
-
56
- Or you can install the dependencies in your own setup. To use Solid with JSX (_recommended_), run:
57
-
58
- ```sh
59
- > npm i -D babel-preset-solid
60
- > npm i solid-js
61
- ```
62
-
63
- The easiest way to get set up is to add `babel-preset-solid` to your `.babelrc`, babel config for webpack, or rollup configuration:
64
-
65
- ```js
66
- "presets": ["solid"]
67
- ```
68
-
69
- For TypeScript to work, remember to set your `.tsconfig` to handle Solid's JSX:
70
-
71
- ```js
72
- "compilerOptions": {
73
- "jsx": "preserve",
74
- "jsxImportSource": "solid-js",
75
- }
76
- ```
77
-
78
- </details>
79
8
 
80
- ## Why Solid?
9
+ **[Website](https://www.solidjs.com/) [API Docs](https://docs.solidjs.com/) • [Tutorial](https://www.solidjs.com/tutorial/introduction_basics) • [GitHub](https://github.com/solidjs/solid) • [Discord](https://discord.com/invite/solidjs)**
81
10
 
82
- ### Performant
11
+ > **You are looking at Solid 2.0 (experimental beta).**
12
+ > Public surface differs from 1.x — split-phase `createEffect`, microtask batching, `Loading`/`Errored` boundaries, draft-first store setters, async-in-computations, removed `solid-js/web` and `solid-js/store` subpaths, and more.
13
+ >
14
+ > - **Migrating from 1.x?** Read [MIGRATION.md](https://github.com/solidjs/solid/blob/next/documentation/solid-2.0/MIGRATION.md) (full guide).
15
+ > - **Need a quick API reference?** See [CHEATSHEET.md](./CHEATSHEET.md) (one page, every public export — ships with this package).
16
+ > - **Looking for stable Solid 1.x?** Use the default [`main` branch](https://github.com/solidjs/solid).
83
17
 
84
- 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](https://krausest.github.io/js-framework-benchmark/current.html)). Solid is [small](https://bundlephobia.com/package/solid-js@1.3.15) and completely tree-shakable, and [fast](https://levelup.gitconnected.com/how-we-wrote-the-fastest-javascript-ui-framework-again-db097ddd99b6) 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](https://dev.to/ryansolid/thinking-granular-how-is-solidjs-so-performant-4g37) from the library's creator.)
18
+ Solid is a declarative JavaScript library for building user interfaces. Instead of a Virtual DOM, it compiles templates to real DOM nodes and updates them with fine-grained reactivity. Declare your state and use it throughout your app when a piece of state changes, only the code that depends on it re-runs.
85
19
 
86
- ### Powerful
20
+ ## At a glance (Solid 2.0)
87
21
 
88
- 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](https://www.solidjs.com/tutorial/introduction_basics).)
89
-
90
- ### Pragmatic
91
-
92
- 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.
93
-
94
- ### Productive
95
-
96
- 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](https://github.com/solidjs-community/solid-primitives), [component libraries](https://github.com/hope-ui/hope-ui), and build-time utilities that let you [write Solid code in new ways](https://github.com/LXSMNSYC/solid-labels).
97
-
98
- <details>
99
- <summary>Show Me!</summary>
100
-
101
- ```jsx
102
- import { render } from "solid-js/web";
22
+ ```tsx
103
23
  import { createSignal } from "solid-js";
24
+ import { render } from "@solidjs/web";
104
25
 
105
- // A component is just a function that (optionally) accepts properties and returns a DOM node
106
- const Counter = props => {
107
- // Create a piece of reactive state, giving us a accessor, count(), and a setter, setCount()
108
- const [count, setCount] = createSignal(props.startingCount || 1);
109
-
110
- // The increment function calls the setter
111
- const increment = () => setCount(count() + 1);
26
+ function Counter() {
27
+ const [count, setCount] = createSignal(0);
28
+ const doubled = () => count() * 2;
112
29
 
113
- console.log(
114
- "The body of the function runs once, like you'd expect from calling any other function, so you only ever see this console log once."
115
- );
116
-
117
- // JSX allows us to write HTML within our JavaScript function and include dynamic expressions using the { } syntax
118
- // The only part of this that will ever rerender is the count() text.
119
30
  return (
120
- <button type="button" onClick={increment}>
121
- Increment {count()}
31
+ <button onClick={() => setCount(c => c + 1)}>
32
+ {doubled()}
122
33
  </button>
123
34
  );
124
- };
35
+ }
125
36
 
126
- // The render function mounts a component onto your page
127
- render(() => <Counter startingCount={2} />, document.getElementById("app"));
37
+ render(() => <Counter />, document.getElementById("app")!);
128
38
  ```
129
39
 
130
- See it in action in our interactive [Playground](https://playground.solidjs.com/?hash=-894962706&version=1.3.13)!
131
-
132
- Solid compiles our JSX down to efficient real DOM expressions updates, still using 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:
133
-
134
- ```js
135
- import { render, createComponent, delegateEvents, insert, template } from "solid-js/web";
136
- import { createSignal } from "solid-js";
137
-
138
- const _tmpl$ = /*#__PURE__*/ template(`<button type="button">Increment </button>`, 2);
40
+ Try it in our [Playground](https://playground.solidjs.com/). _(The hosted Playground currently runs Solid 1.x — a 2.0 build is on the way.)_
139
41
 
140
- const Counter = props => {
141
- const [count, setCount] = createSignal(props.startingCount || 1);
142
- const increment = () => setCount(count() + 1);
42
+ The component body runs **once**. The `{doubled()}` expression is the only thing that re-renders when `count` changes — Solid compiles JSX to real DOM nodes and tracks the `count()` read at that one DOM position.
143
43
 
144
- console.log("The body of the function runs once . . .");
44
+ ## Install
145
45
 
146
- return (() => {
147
- //_el$ is a real DOM node!
148
- const _el$ = _tmpl$.cloneNode(true);
149
- _el$.firstChild;
150
-
151
- _el$.$$click = increment;
152
-
153
- //This inserts the count as a child of the button in a way that allows count to update without rerendering the whole button
154
- insert(_el$, count, null);
155
-
156
- return _el$;
157
- })();
158
- };
159
-
160
- render(
161
- () =>
162
- createComponent(Counter, {
163
- startingCount: 2
164
- }),
165
- document.getElementById("app")
166
- );
167
-
168
- delegateEvents(["click"]);
46
+ ```sh
47
+ npm i solid-js @solidjs/web
48
+ npm i -D babel-preset-solid
169
49
  ```
170
50
 
171
- </details>
172
-
173
- ## More
51
+ Add `babel-preset-solid` to your Babel config (or use Vite's Solid plugin), and set `tsconfig.json`:
174
52
 
175
- Check out our official [documentation](https://www.solidjs.com/guide) or browse some [examples](https://github.com/solidjs/solid/blob/main/documentation/resources/examples.md)
176
-
177
- ## Browser Support
178
-
179
- 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.
180
-
181
- <img src="https://saucelabs.github.io/images/opensauce/powered-by-saucelabs-badge-gray.svg?sanitize=true" alt="Testing Powered By SauceLabs" width="300"/>
182
-
183
- ## Community
184
-
185
- Come chat with us on [Discord](https://discord.com/invite/solidjs)! Solid's creator and the rest of the core team are active there, and we're always looking for contributions.
53
+ ```json
54
+ {
55
+ "compilerOptions": {
56
+ "jsx": "preserve",
57
+ "jsxImportSource": "solid-js"
58
+ }
59
+ }
60
+ ```
186
61
 
187
- ### Contributors
62
+ Existing 1.x starter templates target 1.x — 2.0 starter templates are tracked at [solidjs/templates](https://github.com/solidjs/templates).
188
63
 
189
- <a href="https://github.com/solidjs/solid/graphs/contributors"><img src="https://opencollective.com/solid/contributors.svg?width=890&amp;button=false" style="max-width:100%;"></a>
64
+ ## For LLMs / AI assistants
190
65
 
191
- ### Open Collective
66
+ If you're an AI tool or model generating Solid 2.0 code: the public API differs from any Solid examples that predate 2.0. Read [`CHEATSHEET.md`](./CHEATSHEET.md) before generating — it lives inside this package (`node_modules/solid-js/CHEATSHEET.md`) for that reason. The bottom of the cheatsheet enumerates the specific patterns that changed from 1.x.
192
67
 
193
- Support us with a donation and help us continue our activities. [[Contribute](https://opencollective.com/solid)]
68
+ The full migration guide is [`MIGRATION.md`](https://github.com/solidjs/solid/blob/next/documentation/solid-2.0/MIGRATION.md). Eight RFCs covering each subsystem (reactivity, control flow, stores, async, actions, DOM, dev-mode diagnostics) live alongside it under [`documentation/solid-2.0/`](https://github.com/solidjs/solid/tree/next/documentation/solid-2.0).
194
69
 
195
- <a href="https://opencollective.com/solid/backer/0/website" target="_blank"><img src="https://opencollective.com/solid/backer/0/avatar.svg"></a>
196
- <a href="https://opencollective.com/solid/backer/1/website" target="_blank"><img src="https://opencollective.com/solid/backer/1/avatar.svg"></a>
197
- <a href="https://opencollective.com/solid/backer/2/website" target="_blank"><img src="https://opencollective.com/solid/backer/2/avatar.svg"></a>
198
- <a href="https://opencollective.com/solid/backer/3/website" target="_blank"><img src="https://opencollective.com/solid/backer/3/avatar.svg"></a>
199
- <a href="https://opencollective.com/solid/backer/4/website" target="_blank"><img src="https://opencollective.com/solid/backer/4/avatar.svg"></a>
200
- <a href="https://opencollective.com/solid/backer/5/website" target="_blank"><img src="https://opencollective.com/solid/backer/5/avatar.svg"></a>
201
- <a href="https://opencollective.com/solid/backer/6/website" target="_blank"><img src="https://opencollective.com/solid/backer/6/avatar.svg"></a>
202
- <a href="https://opencollective.com/solid/backer/7/website" target="_blank"><img src="https://opencollective.com/solid/backer/7/avatar.svg"></a>
203
- <a href="https://opencollective.com/solid/backer/8/website" target="_blank"><img src="https://opencollective.com/solid/backer/8/avatar.svg"></a>
204
- <a href="https://opencollective.com/solid/backer/9/website" target="_blank"><img src="https://opencollective.com/solid/backer/9/avatar.svg"></a>
205
- <a href="https://opencollective.com/solid/backer/10/website" target="_blank"><img src="https://opencollective.com/solid/backer/10/avatar.svg"></a>
70
+ ## Learn more
206
71
 
207
- ### Sponsors
72
+ - **Why Solid, key features, browser support, community, sponsors** — see the [repository README](https://github.com/solidjs/solid#readme).
73
+ - **Full documentation** — [docs.solidjs.com](https://docs.solidjs.com).
74
+ - **Examples** — [documentation/resources/examples.md](https://github.com/solidjs/solid/blob/next/documentation/resources/examples.md).
75
+ - **Discord** — [discord.com/invite/solidjs](https://discord.com/invite/solidjs).
208
76
 
209
- Become a sponsor and get your logo on our README on GitHub with a link to your site. [[Become a sponsor](https://opencollective.com/solid#sponsor)]
77
+ ---
210
78
 
211
- <a href="https://opencollective.com/solid/sponsor/0/website" target="_blank"><img src="https://opencollective.com/solid/sponsor/0/avatar.svg"></a>
212
- <a href="https://opencollective.com/solid/sponsor/1/website" target="_blank"><img src="https://opencollective.com/solid/sponsor/1/avatar.svg"></a>
213
- <a href="https://opencollective.com/solid/sponsor/2/website" target="_blank"><img src="https://opencollective.com/solid/sponsor/2/avatar.svg"></a>
214
- <a href="https://opencollective.com/solid/sponsor/3/website" target="_blank"><img src="https://opencollective.com/solid/sponsor/3/avatar.svg"></a>
215
- <a href="https://opencollective.com/solid/sponsor/4/website" target="_blank"><img src="https://opencollective.com/solid/sponsor/4/avatar.svg"></a>
216
- <a href="https://opencollective.com/solid/sponsor/5/website" target="_blank"><img src="https://opencollective.com/solid/sponsor/5/avatar.svg"></a>
217
- <a href="https://opencollective.com/solid/sponsor/6/website" target="_blank"><img src="https://opencollective.com/solid/sponsor/6/avatar.svg"></a>
218
- <a href="https://opencollective.com/solid/sponsor/7/website" target="_blank"><img src="https://opencollective.com/solid/sponsor/7/avatar.svg"></a>
219
- <a href="https://opencollective.com/solid/sponsor/8/website" target="_blank"><img src="https://opencollective.com/solid/sponsor/8/avatar.svg"></a>
220
- <a href="https://opencollective.com/solid/sponsor/9/website" target="_blank"><img src="https://opencollective.com/solid/sponsor/9/avatar.svg"></a>
221
- <a href="https://opencollective.com/solid/sponsor/10/website" target="_blank"><img src="https://opencollective.com/solid/sponsor/10/avatar.svg"></a>
222
- <a href="https://opencollective.com/solid/sponsor/11/website" target="_blank"><img src="https://opencollective.com/solid/sponsor/11/avatar.svg"></a>
223
- <a href="https://opencollective.com/solid/sponsor/12/website" target="_blank"><img src="https://opencollective.com/solid/sponsor/12/avatar.svg"></a>
79
+ _This is the npm package README for `solid-js`. The full repository README — including the monorepo layout, contributors, and sponsors — lives at [github.com/solidjs/solid](https://github.com/solidjs/solid#readme)._
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "solid-js",
3
- "description": "A declarative JavaScript library for building user interfaces.",
4
- "version": "2.0.0-beta.8",
3
+ "description": "Reactive JavaScript library for building user interfaces. Compiles JSX to real DOM with fine-grained signal-based updates — no virtual DOM.",
4
+ "version": "2.0.0-beta.9",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "https://github.com/solidjs/solid"
10
+ "url": "git+https://github.com/solidjs/solid.git",
11
+ "directory": "packages/solid"
11
12
  },
12
13
  "main": "./dist/server.cjs",
13
14
  "module": "./dist/server.js",
@@ -20,7 +21,8 @@
20
21
  "types",
21
22
  "types-cjs",
22
23
  "jsx-runtime.d.ts",
23
- "package.json"
24
+ "package.json",
25
+ "CHEATSHEET.md"
24
26
  ],
25
27
  "exports": {
26
28
  ".": {
@@ -126,7 +128,7 @@
126
128
  "performance"
127
129
  ],
128
130
  "dependencies": {
129
- "@solidjs/signals": "^2.0.0-beta.8",
131
+ "@solidjs/signals": "^2.0.0-beta.9",
130
132
  "csstype": "^3.1.0",
131
133
  "seroval": "~1.5.0",
132
134
  "seroval-plugins": "~1.5.0"
@@ -63,7 +63,39 @@ export type ComponentProps<T extends ValidComponent> = T extends Component<infer
63
63
  * @example Component<{ref: Ref<Element>}>
64
64
  */
65
65
  export type Ref<T> = T | ((val: T) => void);
66
+ /**
67
+ * Invokes a component, wrapping the call in `untrack` so that reactive reads
68
+ * inside the component body don't subscribe the parent computation. Compiled
69
+ * JSX uses this internally; manual calls are rarely needed unless authoring a
70
+ * custom JSX factory or renderer.
71
+ */
66
72
  export declare function createComponent<T extends Record<string, any>>(Comp: Component<T>, props: T): JSX.Element;
73
+ /**
74
+ * Defines a code-split component. The returned component triggers its dynamic
75
+ * import on first render and suspends through any enclosing `<Loading>`
76
+ * boundary while the chunk is in flight. Call `.preload()` to start the
77
+ * import early (e.g. on hover).
78
+ *
79
+ * @param fn dynamic import returning the module's default export
80
+ * @param moduleUrl optional module URL used during hydration to look up
81
+ * preloaded chunks; usually injected by the bundler integration
82
+ *
83
+ * @example
84
+ * ```tsx
85
+ * const Profile = lazy(() => import("./Profile"));
86
+ *
87
+ * function App() {
88
+ * return (
89
+ * <Loading fallback={<Spinner />}>
90
+ * <Profile id="42" />
91
+ * </Loading>
92
+ * );
93
+ * }
94
+ *
95
+ * // Preload before the user clicks
96
+ * <button onMouseEnter={() => Profile.preload()}>Open profile</button>
97
+ * ```
98
+ */
67
99
  export declare function lazy<T extends Component<any>>(fn: () => Promise<{
68
100
  default: T;
69
101
  }>, moduleUrl?: string): T & {
@@ -72,4 +104,22 @@ export declare function lazy<T extends Component<any>>(fn: () => Promise<{
72
104
  }>;
73
105
  moduleUrl?: string;
74
106
  };
107
+ /**
108
+ * Returns a stable id string that matches between server-rendered and
109
+ * client-hydrated trees. Use it for `<label for>`, `aria-labelledby`, and
110
+ * other attributes that need consistent ids across SSR.
111
+ *
112
+ * @example
113
+ * ```tsx
114
+ * function Field(props: { label: string }) {
115
+ * const id = createUniqueId();
116
+ * return (
117
+ * <>
118
+ * <label for={id}>{props.label}</label>
119
+ * <input id={id} />
120
+ * </>
121
+ * );
122
+ * }
123
+ * ```
124
+ */
75
125
  export declare function createUniqueId(): string;
@@ -9,34 +9,101 @@ export type ContextProviderComponent<T> = FlowComponent<{
9
9
  }>;
10
10
  export interface Context<T> extends ContextProviderComponent<T> {
11
11
  id: symbol;
12
- defaultValue: T;
12
+ defaultValue: T | undefined;
13
13
  }
14
14
  /**
15
- * Creates a Context to handle a state scoped for the children of a component
16
- * ```typescript
17
- * interface Context<T> {
18
- * id: symbol;
19
- * Provider: FlowComponent<{ value: T }>;
20
- * defaultValue: T;
15
+ * Creates a Context for sharing state with descendants of a Provider in the
16
+ * component tree.
17
+ *
18
+ * The returned `Context` is itself a provider component — pass it a `value`
19
+ * prop to scope a value to its children. Read it inside descendants with
20
+ * `useContext`.
21
+ *
22
+ * Two forms:
23
+ *
24
+ * - **`createContext<T>()`** (default-less, the canonical form). Reading via
25
+ * `useContext` outside an enclosing Provider throws `ContextNotFoundError`.
26
+ * Use this for everything that carries reactive state — signals, stores,
27
+ * `[state, actions]` tuples, services. The Provider is mandatory by
28
+ * construction; the throw makes a missing Provider a loud bug instead of a
29
+ * silent no-op. The annotation `<T>` is required because there is no value
30
+ * to infer from.
31
+ * - **`createContext<T>(defaultValue)`** (default form). Reserved for the
32
+ * narrow case of contexts whose value is a primitive with a meaningful
33
+ * static fallback (theme, locale, frozen config). Outside any Provider,
34
+ * `useContext` returns `defaultValue`.
35
+ *
36
+ * If you want truly app-wide state, **don't use Context** — a module-scope
37
+ * signal/store *is* a global. Context is for scoping state to a subtree;
38
+ * that's why a Provider is required.
39
+ *
40
+ * @param defaultValue optional default; only meaningful for primitive
41
+ * fallbacks. Omit for any context carrying reactive state.
42
+ * @param options `{ name }` for debugging in development
43
+ * @returns a context object that doubles as its own provider component
44
+ *
45
+ * @example
46
+ * ```tsx
47
+ * // Reactive payload — default-less, throws if no Provider.
48
+ * type TodosCtx = readonly [Store<Todo[]>, TodoActions];
49
+ * const TodosContext = createContext<TodosCtx>();
50
+ *
51
+ * function App() {
52
+ * return (
53
+ * <TodosContext value={createTodos()}>
54
+ * <TodoList />
55
+ * </TodosContext>
56
+ * );
57
+ * }
58
+ *
59
+ * function TodoList() {
60
+ * const [todos, { addTodo }] = useContext(TodosContext); // typed as TodosCtx
61
+ * // ...
62
+ * }
63
+ * ```
64
+ *
65
+ * @example
66
+ * ```tsx
67
+ * // Primitive default — falls back to "light" outside a Provider.
68
+ * const ThemeContext = createContext<"light" | "dark">("light");
69
+ *
70
+ * function Button() {
71
+ * const theme = useContext(ThemeContext); // "light" | "dark"
72
+ * return <button class={theme}>Click</button>;
21
73
  * }
22
- * export function createContext<T>(
23
- * defaultValue?: T,
24
- * options?: { name?: string }
25
- * ): Context<T | undefined>;
26
74
  * ```
27
- * @param defaultValue optional default to inject into context
28
- * @param options allows to set a name in dev mode for debugging purposes
29
- * @returns The context that contains the Provider Component and that can be used with `useContext`
30
75
  *
31
76
  * @description https://docs.solidjs.com/reference/component-apis/create-context
32
77
  */
33
- export declare function createContext<T>(defaultValue?: undefined, options?: EffectOptions): Context<T | undefined>;
34
- export declare function createContext<T>(defaultValue: T, options?: EffectOptions): Context<T>;
78
+ export declare function createContext<T>(defaultValue?: T, options?: EffectOptions): Context<T>;
35
79
  /**
36
- * Uses a context to receive a scoped state from a parent's Context.Provider
80
+ * Reads the current value of a context.
81
+ *
82
+ * - For `createContext<T>()` (default-less): returns the value from the
83
+ * nearest enclosing Provider, or throws `ContextNotFoundError` if none is
84
+ * mounted. Return type is `T` (no narrowing required).
85
+ * - For `createContext<T>(defaultValue)`: returns the value from the nearest
86
+ * enclosing Provider, or `defaultValue` if none is mounted.
37
87
  *
38
- * @param context Context object made by `createContext`
39
- * @returns the current or `defaultValue`, if present
88
+ * In Solid, `useContext` is the canonical way to read context. There is no
89
+ * need for a wrapper hook that throws on missing Provider — the default-less
90
+ * form already does that, and its return type is `T`.
91
+ *
92
+ * @param context a context returned from `createContext`
93
+ * @returns the value provided by the nearest enclosing Provider, or the
94
+ * default if one was supplied to `createContext`
95
+ * @throws `ContextNotFoundError` if no Provider is mounted and the context
96
+ * was created without a default
97
+ *
98
+ * @example
99
+ * ```tsx
100
+ * const TodosContext = createContext<TodosCtx>();
101
+ *
102
+ * function TodoList() {
103
+ * const [todos, { addTodo }] = useContext(TodosContext); // throws if no Provider
104
+ * // ...
105
+ * }
106
+ * ```
40
107
  *
41
108
  * @description https://docs.solidjs.com/reference/component-apis/use-context
42
109
  */
@@ -47,10 +114,20 @@ export type ChildrenReturn = Accessor<ResolvedChildren> & {
47
114
  toArray: () => ResolvedJSXElement[];
48
115
  };
49
116
  /**
50
- * Resolves child elements to help interact with children
117
+ * Resolves a `children` accessor and exposes the result as an accessor with
118
+ * a `.toArray()` helper. Use this when a component needs to inspect or
119
+ * iterate over its children rather than just render them through.
51
120
  *
52
121
  * @param fn an accessor for the children
53
- * @returns a accessor of the same children, but resolved
122
+ * @returns an accessor of the resolved children, with `.toArray()` for iteration
123
+ *
124
+ * @example
125
+ * ```tsx
126
+ * function List(props: { children: JSX.Element }) {
127
+ * const items = children(() => props.children);
128
+ * return <ul>{items.toArray().map(item => <li>{item}</li>)}</ul>;
129
+ * }
130
+ * ```
54
131
  *
55
132
  * @description https://docs.solidjs.com/reference/component-apis/children
56
133
  */
@@ -41,7 +41,21 @@ export declare function Repeat<T extends JSX.Element>(props: {
41
41
  children: ((index: number) => T) | T;
42
42
  }): JSX.Element;
43
43
  /**
44
- * Conditionally render its children or an optional fallback component
44
+ * Conditionally renders its children when `when` is truthy, otherwise renders
45
+ * the optional `fallback`.
46
+ *
47
+ * The function-child form receives an accessor for the narrowed value — call
48
+ * it to read. Without `keyed` (default), the child is preserved across
49
+ * truthy values; with `keyed`, the child remounts whenever the value's
50
+ * identity changes.
51
+ *
52
+ * @example
53
+ * ```tsx
54
+ * <Show when={user()} fallback={<SignIn />}>
55
+ * {u => <Greeting name={u().name} />}
56
+ * </Show>
57
+ * ```
58
+ *
45
59
  * @description https://docs.solidjs.com/reference/components/show
46
60
  */
47
61
  export declare function Show<T, F extends ConditionalRenderCallback<T>>(props: {
@@ -74,12 +88,24 @@ export type MatchProps<T, F extends ConditionalRenderCallback<T> = ConditionalRe
74
88
  children: ConditionalRenderChildren<T, F>;
75
89
  };
76
90
  /**
77
- * Selects a content based on condition when inside a `<Switch>` control flow
78
- * ```typescript
79
- * <Match when={condition()}>
80
- * <Content/>
81
- * </Match>
91
+ * A branch inside a `<Switch>`. The first `<Match>` whose `when` is truthy
92
+ * wins; remaining matches are skipped.
93
+ *
94
+ * Like `<Show>`, `<Match>` supports a function child that receives an
95
+ * accessor for the narrowed value.
96
+ *
97
+ * @example
98
+ * ```tsx
99
+ * <Switch fallback={<NotFound />}>
100
+ * <Match when={user()}>
101
+ * {u => <Profile name={u().name} />}
102
+ * </Match>
103
+ * <Match when={loading()}>
104
+ * <Spinner />
105
+ * </Match>
106
+ * </Switch>
82
107
  * ```
108
+ *
83
109
  * @description https://docs.solidjs.com/reference/components/switch-and-match
84
110
  */
85
111
  export declare function Match<T, F extends ConditionalRenderCallback<T>>(props: MatchProps<T, F>): JSX.Element;
@@ -103,14 +129,40 @@ export declare function Errored(props: {
103
129
  children: JSX.Element;
104
130
  }): JSX.Element;
105
131
  /**
106
- * Tracks all resources inside a component and renders a fallback until they are all resolved
107
- * ```typescript
108
- * const AsyncComponent = lazy(() => import('./component'));
132
+ * Renders a `fallback` while pending async reads inside the subtree settle.
133
+ *
134
+ * Any computation (`createMemo`, `createSignal(fn)`, `createStore(fn)`,
135
+ * `lazy(...)`, etc.) that throws because data isn't ready is caught by the
136
+ * nearest enclosing `<Loading>`. The boundary swaps to its `fallback` until
137
+ * every pending read has resolved, then renders the children.
138
+ *
139
+ * The optional `on` prop scopes the boundary so it ignores transitions
140
+ * caused by writes to other reactive sources — those transitions stay on the
141
+ * previous content (with `isPending()` flipping during the transition).
142
+ *
143
+ * Scope `<Loading>` around the data-dependent slot, not the surrounding
144
+ * shell. Wrapping layout chrome (header, nav, footer) in the same boundary
145
+ * as the data means revalidation replaces the entire screen with the
146
+ * fallback; rendering chrome outside the boundary keeps it stable while
147
+ * only the affordance flips.
109
148
  *
110
- * <Loading fallback={<LoadingIndicator />}>
111
- * <AsyncComponent />
149
+ * @example
150
+ * ```tsx
151
+ * const Profile = lazy(() => import("./Profile"));
152
+ *
153
+ * <Loading fallback={<Spinner />}>
154
+ * <Profile />
112
155
  * </Loading>
113
156
  * ```
157
+ *
158
+ * @example
159
+ * ```tsx
160
+ * // Only show the fallback for transitions caused by writes to `route`.
161
+ * <Loading fallback={<Skeleton />} on={route}>
162
+ * <Page />
163
+ * </Loading>
164
+ * ```
165
+ *
114
166
  * @description https://docs.solidjs.com/reference/components/suspense
115
167
  */
116
168
  export declare function Loading(props: {