Skip to content

experimental: Solid 2.0 migration powered by AI#1437

Open
davedbase wants to merge 17 commits intosolidjs:mainfrom
davedbase:solid2-docs
Open

experimental: Solid 2.0 migration powered by AI#1437
davedbase wants to merge 17 commits intosolidjs:mainfrom
davedbase:solid2-docs

Conversation

@davedbase
Copy link
Member

This is an implementation of the docs generated from RFCs for Solid 2.0. Claude was prompted to use the PLAN.md and a cloned copy of the RFCs in the new-docs folder. It was tasked to outline what the 2.0 docs would look like. Note that this is an experiment to evaluate how close it got with little effort or guidance. This PR will either be deleted or evolved into additional docs for the 2.0 beta release.

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@netlify
Copy link

netlify bot commented Mar 4, 2026

Deploy Preview for solid-docs ready!

Name Link
🔨 Latest commit 57120cd
🔍 Latest deploy log https://app.netlify.com/projects/solid-docs/deploys/69a7ac0b8f179d0008b090ad
😎 Deploy Preview https://deploy-preview-1437--solid-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment on lines +162 to +182
## Mutations: `action` + `refresh`

Reading async data is handled by computations and boundaries.
**Writing** data — mutations — uses a different tool: [`action()`](/reference/reactive-utilities/action).

An action wraps a generator function that can perform optimistic writes, async work, and refresh coordination in a structured way:

```ts
import { action, refresh } from "solid-js"
import { createStore } from "solid-js/store"

const [todos] = createStore(() => api.getTodos(), { list: [] })

const addTodo = action(function* (todo) {
yield api.addTodo(todo) // async work
refresh(todos) // re-fetch the source data
})
```

Actions run inside a transition. When the action completes and `refresh()` fires, the derived data recomputes and the UI updates.
See the [Fetching Data](/guides/fetching-data) guide for the full mutation and optimistic update patterns.
Copy link
Contributor

Choose a reason for hiding this comment

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

actions are only needed to tie optimistic updates with async updates/refresh. This section should be combined with Optimistic updates below - no need to use actions if you are not setting optimistic data inside them.

Comment on lines +184 to +191
## Optimistic updates

For instant UI feedback during mutations, Solid 2.0 provides two optimistic primitives:

- [`createOptimistic`](/reference/reactive-utilities/create-optimistic) — a signal whose writes revert when the transition completes
- [`createOptimisticStore`](/reference/reactive-utilities/create-optimistic-store) — the store equivalent

Optimistic values overlay on top of a source during a transition and automatically roll back when the transition settles (on both success and failure):
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace transition with action, and in general i think we want to avoid talking about transitions if possible

Comment on lines +197 to +201
const [todos] = createStore(() => api.getTodos(), { list: [] })
const [optimisticTodos, setOptimisticTodos] = createOptimisticStore(
() => snapshot(todos),
{ list: [] }
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const [todos] = createStore(() => api.getTodos(), { list: [] })
const [optimisticTodos, setOptimisticTodos] = createOptimisticStore(
() => snapshot(todos),
{ list: [] }
)
const [todos, setOptimisticTodos] = createOptimisticStore(
() => api.getTodos(),
{ list: [] }
)

Comment on lines +228 to +240
## Error handling

Errors in async computations are caught by [`<Errored>`](/reference/components/error-boundary) boundaries, just like synchronous errors:

```tsx
<Errored fallback={(err) => <p>Something went wrong: {err.message}</p>}>
<Loading fallback={<Spinner />}>
<UserProfile />
</Loading>
</Errored>
```

If a fetch rejects or a computation throws, the nearest `<Errored>` boundary renders its fallback.
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth adding an example with the retry method as well

## When to use `<For>` vs `<Repeat>`

- Use `<For>` when rendering from a **data array** where items have identity and may change, reorder, or be filtered.
- Use `<Repeat>` when rendering a **fixed count** of items (skeletons, ranges, grids) where no list diffing is needed.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure the point about Repeat is accurate - it's not for fixed count of items, but for arrays where things don't move around much (chats, logs, etc). Probably gonna need some workshopping.

<For each={tasks()}>
{(task) => {
const { id, text } = task
const { id, text } = task()
Copy link
Contributor

Choose a reason for hiding this comment

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

reading a signal top level bad


- `err`: The caught error object.
- `reset`: A function that forces the `<ErrorBoundary>` to re-render its children and clear the error state.
- `reset`: A function that forces `<Errored>` to re-render its children and clear the error state.
Copy link
Contributor

Choose a reason for hiding this comment

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

reset doesn't force rerender of the children, it forces a rerun of the errored computations and nothing else

function Repeat(props: {
count: number
from?: number
children: (index: () => number) => JSX.Element
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
children: (index: () => number) => JSX.Element
children: (index: number) => JSX.Element

Index isn't an accessor since it can't change

Comment on lines +66 to +73
Use `<Repeat>` when:
- You need to render a fixed number of elements (e.g., star ratings, pagination dots, grid cells)
- The content doesn't come from a data array
- You don't need list diffing or keying

Use `<For>` when:
- You're rendering items from a data array
- Items have identity and may be reordered, added, or removed
Copy link
Contributor

Choose a reason for hiding this comment

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

Definitely gonna need more workshopping

Comment on lines +13 to +30
description: >-
Run code after component rendering is complete with onSettled. Replaces
onMount with added cleanup support and clearer semantics.
---

```ts
import { onSettled } from "solid-js"

function onSettled(fn: () => void | (() => void)): void
```

`onSettled` registers a callback that runs once after the component's initial render is complete and the DOM is ready. It replaces `onMount` from Solid 1.x.

## Key differences from `onMount`

- **Can return a cleanup function** — the returned function runs when the component is disposed
- **Cannot create nested reactive primitives** — don't call `createSignal`, `createEffect`, etc. inside the callback

Copy link
Contributor

Choose a reason for hiding this comment

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

Also gonna need workshopping
The key change is the onSettled can be called from event handlers as well, where it will queue the callback to run after any updates made in the event are settled/flushed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants