Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
30ba3de
docs: enhance documentation for batch, onCleanup, onMount, and untrack
LadyBluenotes Apr 3, 2026
80c4b9d
docs: update descriptions for batch, catchError, getOwner, onCleanup,…
LadyBluenotes Apr 3, 2026
da1b83e
docs: update documentation for createReaction, startTransition, and u…
LadyBluenotes Apr 3, 2026
d448223
docs: update documentation for from, indexArray, mapArray, and observ…
LadyBluenotes Apr 3, 2026
c4de20b
docs: refine documentation for children, createContext, useContext, a…
LadyBluenotes Apr 3, 2026
67a8923
docs: update documentation for createContext, createDeferred, createR…
LadyBluenotes Apr 3, 2026
2057f6a
docs: update documentation for <Dynamic>, mergeProps, <Portal>, and s…
LadyBluenotes Apr 3, 2026
0374d22
docs: update documentation for <Dynamic>, mergeProps, <Portal>, and s…
LadyBluenotes Apr 3, 2026
b1c0bd4
docs: update documentation for <Dynamic>, mergeProps, <Portal>, and s…
LadyBluenotes Apr 3, 2026
e2091bc
migrate rendering reference pages and split isDev
LadyBluenotes Apr 3, 2026
e3b30c6
migrate server rendering reference pages
LadyBluenotes Apr 3, 2026
ed22b63
migrate server rendering reference pages
LadyBluenotes Apr 3, 2026
6d1abb5
migrate store creation and mutable store refs
LadyBluenotes Apr 3, 2026
b389663
migrate store creation and mutable store refs
LadyBluenotes Apr 3, 2026
313cd7a
migrate jsx attribute refs and attribute directives
LadyBluenotes Apr 3, 2026
20117b9
add warning to suspense list
LadyBluenotes Apr 3, 2026
921e3b1
jsx styling and content attribute refs
LadyBluenotes Apr 3, 2026
759a60b
jsx event and directive reference pages
LadyBluenotes Apr 3, 2026
d992ace
update children
LadyBluenotes Apr 3, 2026
599b55c
update
LadyBluenotes Apr 3, 2026
7c4ba3c
update
LadyBluenotes Apr 3, 2026
78ba488
update
LadyBluenotes Apr 3, 2026
6b391a0
update
LadyBluenotes Apr 4, 2026
2bda9b9
update
LadyBluenotes Apr 5, 2026
d00622e
update
LadyBluenotes Apr 5, 2026
b25c82b
update
LadyBluenotes Apr 5, 2026
878aa46
update
LadyBluenotes Apr 5, 2026
8d5a5ae
update
LadyBluenotes Apr 5, 2026
b310a12
update
LadyBluenotes Apr 5, 2026
cc37151
update
LadyBluenotes Apr 5, 2026
4d7eb35
update
LadyBluenotes Apr 5, 2026
b94ffde
update
LadyBluenotes Apr 5, 2026
a252fae
update
LadyBluenotes Apr 5, 2026
ff0dcdb
update
LadyBluenotes Apr 5, 2026
d0217b0
update
LadyBluenotes Apr 5, 2026
0ef73e8
update
LadyBluenotes Apr 5, 2026
bf31ca0
update
LadyBluenotes Apr 5, 2026
9515e10
update
LadyBluenotes Apr 5, 2026
05cfd33
update
LadyBluenotes Apr 6, 2026
b0139d4
update
LadyBluenotes Apr 6, 2026
91b3aba
update
LadyBluenotes Apr 6, 2026
4c2276e
update
LadyBluenotes Apr 6, 2026
783dcd9
update
LadyBluenotes Apr 6, 2026
890f5bb
update
LadyBluenotes Apr 6, 2026
4045d18
update
LadyBluenotes Apr 6, 2026
63e122d
update
LadyBluenotes Apr 6, 2026
13744eb
update
LadyBluenotes Apr 6, 2026
caa8736
update
LadyBluenotes Apr 6, 2026
5dfe7e0
Merge branch 'main' into ref-updates
kodiakhq[bot] Apr 6, 2026
ffede2d
update
LadyBluenotes Apr 6, 2026
a975566
ci: apply automated fixes
autofix-ci[bot] Apr 6, 2026
1c42276
Merge remote-tracking branch 'origin/ref-updates' into ref-updates
LadyBluenotes Apr 6, 2026
cd3aa56
update
LadyBluenotes Apr 6, 2026
5d14672
ci: apply automated fixes
autofix-ci[bot] Apr 6, 2026
8253297
update
LadyBluenotes Apr 6, 2026
c434bbc
Merge remote-tracking branch 'origin/ref-updates' into ref-updates
LadyBluenotes Apr 6, 2026
5c821e0
update
LadyBluenotes Apr 6, 2026
f9b8140
ci: apply automated fixes
autofix-ci[bot] Apr 6, 2026
31e5840
update
LadyBluenotes Apr 6, 2026
4909ac8
Merge remote-tracking branch 'origin/ref-updates' into ref-updates
LadyBluenotes Apr 6, 2026
ff496a5
update
LadyBluenotes Apr 6, 2026
ad3cd90
update
LadyBluenotes Apr 6, 2026
799f08e
update
LadyBluenotes Apr 6, 2026
acad606
update
LadyBluenotes Apr 6, 2026
9ef7a8d
update
LadyBluenotes Apr 6, 2026
2b3e4f9
update
LadyBluenotes Apr 6, 2026
30e49f0
update
LadyBluenotes Apr 6, 2026
de7692a
update
LadyBluenotes Apr 6, 2026
41afcb6
update
LadyBluenotes Apr 6, 2026
cb94434
update
LadyBluenotes Apr 6, 2026
12320a7
update
LadyBluenotes Apr 6, 2026
c6373b3
update
LadyBluenotes Apr 6, 2026
943bf96
update
LadyBluenotes Apr 6, 2026
2b8579a
update
LadyBluenotes Apr 6, 2026
a40025d
update
LadyBluenotes Apr 6, 2026
8110eda
update
LadyBluenotes Apr 6, 2026
41550a3
update
LadyBluenotes Apr 6, 2026
1ba58f3
update
LadyBluenotes Apr 6, 2026
1f10d22
update
LadyBluenotes Apr 6, 2026
41c389d
update
LadyBluenotes Apr 6, 2026
e7d189e
update
LadyBluenotes Apr 6, 2026
b2b8a1b
update
LadyBluenotes Apr 6, 2026
cd19e35
update
LadyBluenotes Apr 6, 2026
b6c3f87
update
LadyBluenotes Apr 6, 2026
ed5a2c7
improve accuracy of docs
LadyBluenotes Apr 6, 2026
431f2f2
ci: apply automated fixes
autofix-ci[bot] Apr 6, 2026
666143c
update docs for accuracy
LadyBluenotes Apr 6, 2026
9ee6e50
Merge remote-tracking branch 'origin/ref-updates' into ref-updates
LadyBluenotes Apr 6, 2026
e0f4812
update docs for accuracy
LadyBluenotes Apr 6, 2026
1e410e6
update docs for accuracy
LadyBluenotes Apr 6, 2026
b7a9c9d
update docs for accuracy
LadyBluenotes Apr 6, 2026
44fe189
update docs for accuracy
LadyBluenotes Apr 6, 2026
27a34a2
update docs for accuracy
LadyBluenotes Apr 6, 2026
6decc54
Merge branch 'main' into ref-updates
kodiakhq[bot] Apr 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions public/llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
- [<Suspense>](https://docs.solidjs.com/reference/components/suspense)
- [<SuspenseList>](https://docs.solidjs.com/reference/components/suspense-list)
- [<Switch> / <Match>](https://docs.solidjs.com/reference/components/switch-and-match)
- [createDynamic](https://docs.solidjs.com/reference/components/create-dynamic)
- [@once](https://docs.solidjs.com/reference/jsx-attributes/once)
- [attr:*](https://docs.solidjs.com/reference/jsx-attributes/attr)
- [bool:*](https://docs.solidjs.com/reference/jsx-attributes/bool)
Expand Down Expand Up @@ -103,6 +104,7 @@
- [DEV](https://docs.solidjs.com/reference/rendering/dev)
- [hydrate](https://docs.solidjs.com/reference/rendering/hydrate)
- [hydrationScript](https://docs.solidjs.com/reference/rendering/hydration-script)
- [isDev](https://docs.solidjs.com/reference/rendering/is-dev)
- [isServer](https://docs.solidjs.com/reference/rendering/is-server)
- [render](https://docs.solidjs.com/reference/rendering/render)
- [renderToStream](https://docs.solidjs.com/reference/rendering/render-to-stream)
Expand All @@ -125,6 +127,7 @@

- [Overview](https://docs.solidjs.com/solid-start/)
- [Getting started](https://docs.solidjs.com/solid-start/getting-started)
- [Migrating from v1](https://docs.solidjs.com/solid-start/migrating-from-v1)
- [Routing](https://docs.solidjs.com/solid-start/building-your-application/routing)
- [API routes](https://docs.solidjs.com/solid-start/building-your-application/api-routes)
- [CSS and styling](https://docs.solidjs.com/solid-start/building-your-application/css-and-styling)
Expand All @@ -137,6 +140,7 @@
- [Sessions](https://docs.solidjs.com/solid-start/advanced/session)
- [Request events](https://docs.solidjs.com/solid-start/advanced/request-events)
- [Returning responses](https://docs.solidjs.com/solid-start/advanced/return-responses)
- [Serialization](https://docs.solidjs.com/solid-start/advanced/serialization)
- [Auth](https://docs.solidjs.com/solid-start/advanced/auth)
- [WebSocket endpoint](https://docs.solidjs.com/solid-start/advanced/websocket)
- [Security](https://docs.solidjs.com/solid-start/guides/security)
Expand Down Expand Up @@ -182,6 +186,7 @@
- [Revalidation](https://docs.solidjs.com/solid-router/data-fetching/revalidation)
- [Preload data](https://docs.solidjs.com/solid-router/data-fetching/how-to/preload-data)
- [Handle pending and error states](https://docs.solidjs.com/solid-router/data-fetching/how-to/handle-error-and-loading-states)
- [Preloading](https://docs.solidjs.com/solid-router/advanced-concepts/preloading)
- [Lazy loading](https://docs.solidjs.com/solid-router/advanced-concepts/lazy-loading)
- [Migration from v0.9.x](https://docs.solidjs.com/solid-router/guides/migration)
- [A](https://docs.solidjs.com/solid-router/reference/components/a)
Expand Down Expand Up @@ -225,3 +230,4 @@
- [MetaProvider](https://docs.solidjs.com/solid-meta/reference/meta/metaprovider)
- [Style](https://docs.solidjs.com/solid-meta/reference/meta/style)
- [Title](https://docs.solidjs.com/solid-meta/reference/meta/title)
- [useHead](https://docs.solidjs.com/solid-meta/reference/meta/use-head)
90 changes: 40 additions & 50 deletions src/routes/reference/component-apis/children.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ tags:
- utilities
version: "1.0"
description: >-
Resolve and normalize a component's `children` prop into a stable accessor.
Useful when you need to read or transform children imperatively inside a
component.
Resolve a component's `children` prop into a stable accessor.
---

`children` normalizes a component's `children` prop into a stable accessor that returns resolved JSX elements.
It accepts functions, arrays, fragments, and nested structures.
`children` resolves a component's `children` prop and returns a stable accessor for the resolved result.

## Import

Expand All @@ -27,10 +24,11 @@ import { children } from "solid-js";
## Type

```ts
function children(fn: Accessor<JSX.Element>): ChildrenReturn;
type ResolvedJSXElement = Exclude<JSX.Element, JSX.ArrayElement>;
type ResolvedChildren = ResolvedJSXElement | ResolvedJSXElement[];

type ChildrenReturn = Accessor<ResolvedChildren> & {
toArray: () => ResolvedChildren[];
function children(fn: Accessor<JSX.Element>): Accessor<ResolvedChildren> & {
toArray: () => ResolvedJSXElement[];
};
```

Expand All @@ -41,24 +39,20 @@ type ChildrenReturn = Accessor<ResolvedChildren> & {
- **Type:** `() => JSX.Element`
- **Required:** Yes

An accessor that returns the `children` value (typically `props.children`).
Accessor that returns the component's `children` value.

## Return value

- **Type:** `ChildrenReturn`
- **Type:** `Accessor<ResolvedChildren> & { toArray: () => ResolvedJSXElement[] }`

The function returns a callable accessor.
Calling it yields the resolved children, either a single element or an array.
Returns an accessor for the resolved children.
The accessor also exposes `toArray()`.

## Helpers
## Behavior

### `toArray()`

- **Type:** `() => ResolvedChildren[]`

- **Description:** Returns a flattened array of resolved child elements.

This method is exposed on the returned accessor and is useful for iteration or index-based logic.
- The returned accessor memoizes the resolved children, so repeated reads use the resolved result instead of recreating the child structure.
- `children` resolves nested arrays, fragments, and zero-argument child accessors from `props.children`.
- `toArray()` returns the resolved children as an array. It returns `[]` when the resolved value is `null` or `undefined`.

## Examples

Expand All @@ -68,53 +62,49 @@ This method is exposed on the returned accessor and is useful for iteration or i
function Wrapper(props) {
const resolved = children(() => props.children);

return <div>{resolved()}</div>;
return (
<div>
<header>{resolved()}</header>
<div>{resolved()}</div>
</div>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think the previous example was better as to not encourage using the resolved children more than once.

If it were text children, then that example would have been ok,
https://playground.solidjs.com/anonymous/3b9366fa-717d-4c0c-8834-d2a69a455361

but if the children happen to be warpped in a div, then that div will only exist in 1 place at a time
https://playground.solidjs.com/anonymous/ca5d31b9-69e6-4609-b8cc-6545834644c0

the children helper wraps the function in a memo, that caches the value, so each time its called, it returns the same thing (as in, it wont create two divs)

);
}

// Usage
<Wrapper>
<span>one</span>
<span>two</span>
</Wrapper>;
function Example() {
return (
<Wrapper>
<span>First</span>
<span>Second</span>
</Wrapper>
);
}
```

### `.toArray()` example
### Flatten children into an array

```tsx
function List(props) {
const resolved = children(() => props.children);
const items = resolved.toArray();

return (
<ul>
{items.map((child) => (
{resolved.toArray().map((child) => (
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call!

<li>{child}</li>
))}
</ul>
);
}

// Usage
<List>
<span>one</span>
<span>two</span>
</List>;
function Example() {
return (
<List>
<span>Alpha</span>
<span>Beta</span>
</List>
);
}
```

> [!NOTE]
> `children` resolves the current value of `props.children`.
> If `props.children` is reactive, the resolved accessor reflects updates.

### Working with function-as-children
## Related

If `children` is a function, the helper evaluates it and returns its rendered result.

```tsx
function Slot(props) {
const resolved = children(() => props.children);
return <div>{resolved()}</div>;
}

// Usage
<Slot>{() => <span>dynamic</span>}</Slot>;
```
- [Props](/concepts/components/props)
150 changes: 74 additions & 76 deletions src/routes/reference/component-apis/create-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,103 +12,101 @@ tags:
- dependency-injection
version: "1.0"
description: >-
Create context providers with createContext to share data across components
without prop drilling. Perfect for themes, auth, and global app state.
Create a context object with a `Provider` component and a default value.
---

Context provides a form of dependency injection in Solid.
It is used to save from needing to pass data as props through intermediate components (aka **prop drilling**).
This function creates a new context object that can be used with [useContext](/reference/component-apis/use-context) and offers the Provider control flow.
The default value is used when no Provider is found above in the hierarchy.
`createContext` creates a context object.
The returned object contains a `Provider` component and an optional `defaultValue`; [`useContext`](/reference/component-apis/use-context) reads the nearest matching provider value.

## Usage
## Import

To avoid reinstatiating a new context when Hot-Module Replacement (HMR) occurs, it is recommended to use `createContext` in its own module (file).
```ts
import { createContext } from "solid-js";
```

## Type

```ts
interface Context<T> {
id: symbol;
Provider: (props: { value: T; children: any }) => any;
defaultValue: T;
}

:::danger[Hot-Module Replacement]
When using HMR, the context is lost when the module is reloaded.
Which will cause an error to be thrown as `useContext` will try to access it while it is still reloading.
:::
function createContext<T>(
defaultValue?: undefined,
options?: { name?: string }
): Context<T | undefined>;

For example:
function createContext<T>(
defaultValue: T,
options?: { name?: string }
): Context<T>;
```

```ts title="/context/counter.ts"
import { createContext } from "solid-js";
## Parameters

export const INITIAL_COUNT = 0;
### `defaultValue`

const INITIAL_STORE_SETTER = {
increment: () => {},
decrement: () => {},
};
- **Type:** `T`

export const CounterContext = createContext([
{ count: INITIAL_COUNT },
INITIAL_STORE_SETTER,
]);
```
Default value returned by [`useContext`](/reference/component-apis/use-context) when no matching provider is found.

With the context created in its own module, you can use to instantiate the context provider.

```ts title="/context/counter-component.tsx"
import { createStore } from 'solid-js/store';
import { CounterContext, INITIAL_COUNT } from "./counter.ts";

export function CounterProvider(props) {
const [value, setValue] = createStore({ count: props.initialCount || INITIAL_COUNT })

const counter = [
value,
{
increment() {
setValue("count", currentCount => currentCount + 1)
},
decrement() {
setValue("count", currentCount => currentCount - 1)
},
},
]

return (
<CounterContext.Provider value={counter}>
{props.children}
</CounterContext.Provider>
)
}
```
### `options`

#### `name`

- **Type:** `string`

A few imporant notes on how to pass data through the context API:
Debug name used by development tooling.

- The value passed to provider is passed to `useContext` as is.
- Wrapping as a reactive expression will not work.
- You should pass in Signals and Stores directly instead of accessing them in the JSX.
## Return value

To learn how to consume the context, see the [useContext](/reference/component-apis/use-context) documentation and the [Context concepts entry](/concepts/context).
- **Type:** `Context<T>` or `Context<T | undefined>`

## Default Values
Returns a context object containing `id`, `Provider`, and `defaultValue`.

`createContext()` takes an optional "default value" as an argument.
If `useContext` is called and there is no corresponding context provider above it in the component hierarchy, then the value passed as `defaultValue` is returned.
## Behavior

However, if no `defaultValue` was passed, then `undefined` is returned in this case.
Also, `defaultValue` (or `undefined`) is returned if `useContext` is called inside an event callback, as it is then outside of the component hierarchy.
- `Context.Provider` passes its `value` prop to descendant calls to [`useContext`](/reference/component-apis/use-context).
- `useContext` reads the nearest matching provider in the current owner tree.
- If no matching provider is found, `useContext` returns `defaultValue` when one was supplied, or `undefined` otherwise.

This has implications for TS.
If no `defaultValue` is passed, then it is possible that `useContext()` will return `undefined`, and the types reflect this.
## Notes

Another (used in the example in the previous section) is provide a default value to `createContext()`.
In that case, `useContext()` will always return a value, and therefore TS will not complain either.
The pitfall with this approach is that if you _unintentionally_ use `useContext` outside of a provider, it may not be immediately apparent, because the context is still providing a valid value.
Therefore, if you expect to always use `useContext` within a provider, it is best to use the error based approach described above.
- During Hot Module Replacement (HMR), recreating a context in a reloaded module creates a new context object.
- If provider and consumer modules are temporarily out of sync during reload, `useContext` can read a different context object and return the default value or `undefined`.
- Defining the context in its own module keeps the exported context object stable across imports.

## Type signature
## Examples

### Create a context with a default value

```ts
interface Context<T> {
id: symbol;
Provider: (props: { value: T; children: any }) => any;
defaultValue: T;
}
import { createContext } from "solid-js";

function createContext<T>(defaultValue?: T): Context<T | undefined>;
type Theme = "light" | "dark";

const ThemeContext = createContext<Theme>("light");
```

### Create a provider

```tsx
import { createContext } from "solid-js";

const CounterContext = createContext<{ count: number }>();

function CounterProvider(props) {
return (
<CounterContext.Provider value={{ count: 1 }}>
{props.children}
</CounterContext.Provider>
);
}
```

## Related

- [`useContext`](/reference/component-apis/use-context)
- [Context](/concepts/context)
Loading
Loading