Skip to content

docs: correct createContext guidance for server rendering - #3395

Merged
ryansolid merged 1 commit into
solidjs:nextfrom
JohannesGezachew:jsdoc-context-ssr-guidance
Sep 12, 2026
Merged

ryansolid merged 1 commit into
solidjs:nextfrom
JohannesGezachew:jsdoc-context-ssr-guidance

Conversation

@JohannesGezachew

Copy link
Copy Markdown

Closes #3390 (except the useContext URL, see below).

createContext guidance

The JSDoc recommended a module-scope signal or store for app-wide state. Under ssr: true a module is evaluated once per process, so that state is shared across requests, and the 2.0 docs advise the opposite. Since the reference page is generated from this JSDoc, the two contradicted each other. This uses the wording from the issue.

Smaller items from the same issue

  • createContext / useContext @example: the TodoList stub had no return value, so the examples fail tsc as written. Added return null;.
  • handleServerFunctionRequest @example: imported from @solidjs/web/server-functions. In packages/web/package.json that subpath resolves to server-functions/dist/client.js under the browser condition, while ./server-functions/server maps unconditionally to the server build, so the example now imports from @solidjs/web/server-functions/server.

Not done

The fourth item, useContext's @description https://docs.solidjs.com/reference/component-apis/use-context being a 1.x URL, is left alone: every @description in the 2.0 source points at docs.solidjs.com/reference/..., including create-context and children directly around it, and the repo has no other docs host, so I could not tell what the intended 2.0 target is. Happy to update this one, and its neighbours if they are stale too, once you name the URL.

Comment-only changes; no runtime code is touched.

The createContext JSDoc told readers to reach for a module-scope
signal or store for app-wide state. With ssr: true a module is
evaluated once per process, so that state is shared by every request:
a store derived from a server function leaks one user's data into
another's render, and a module-scope signal has no owner to dispose
it. The 2.0 docs say the opposite, and the reference page is generated
from this JSDoc, so the site contradicted itself.

Also fix two smaller items in the same examples:

- The createContext and useContext @example blocks render <TodoList />,
  whose stub returns nothing, so the examples fail tsc as written.
- The handleServerFunctionRequest @example imported from
  "@solidjs/web/server-functions", which resolves to the client entry
  under the browser condition; the function is exported from
  "@solidjs/web/server-functions/server".
@changeset-bot

changeset-bot Bot commented Sep 12, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: a69efec

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ryansolid
ryansolid merged commit e02157a into solidjs:next Sep 12, 2026
6 checks passed
@ryansolid

Copy link
Copy Markdown
Member

Merged as e02157a — thanks, and the reasoning on the server-functions/server subpath was exactly right.

Claude via Cursor

@codspeed

codspeed Bot commented Sep 12, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 54.7%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 159 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
projection derive: write one NESTED field (reference) 809.1 µs 523 µs +54.7%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing JohannesGezachew:jsdoc-context-ssr-guidance (a69efec) with next (344ed05)

Open in CodSpeed

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