Skip to content
Open
Changes from 4 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4633f0a
Add a note about using `redirect` with server functions
amirhhashemi Dec 24, 2025
89ee441
update
amirhhashemi Dec 24, 2025
5dcda3c
update
amirhhashemi Dec 28, 2025
66ca74f
Merge branch 'main' into add-note-about-redirects-and-streaming
kodiakhq[bot] Dec 28, 2025
982a202
Merge branch 'main' into add-note-about-redirects-and-streaming
kodiakhq[bot] Dec 28, 2025
6f39414
Merge branch 'main' into add-note-about-redirects-and-streaming
kodiakhq[bot] Dec 28, 2025
5ac360a
Merge branch 'main' into add-note-about-redirects-and-streaming
kodiakhq[bot] Dec 28, 2025
da2325d
Merge branch 'main' into add-note-about-redirects-and-streaming
kodiakhq[bot] Dec 30, 2025
094fb8e
Merge branch 'main' into add-note-about-redirects-and-streaming
kodiakhq[bot] Dec 30, 2025
d12d32b
Merge branch 'main' into add-note-about-redirects-and-streaming
kodiakhq[bot] Dec 30, 2025
928e2a6
Merge branch 'main' into add-note-about-redirects-and-streaming
kodiakhq[bot] Dec 30, 2025
fdab00a
Merge branch 'main' into add-note-about-redirects-and-streaming
kodiakhq[bot] Dec 30, 2025
81d9482
Merge branch 'main' into add-note-about-redirects-and-streaming
kodiakhq[bot] Dec 30, 2025
4a72ae6
Merge branch 'main' into add-note-about-redirects-and-streaming
kodiakhq[bot] Dec 30, 2025
a7eb9e7
update
amirhhashemi Jan 3, 2026
e6750ac
update
amirhhashemi Jan 3, 2026
d6e305f
Update src/routes/solid-start/building-your-application/data-fetching…
amirhhashemi Jan 4, 2026
6641589
Merge branch 'main' into add-note-about-redirects-and-streaming
kodiakhq[bot] Jan 6, 2026
e48ea59
Merge branch 'main' into add-note-about-redirects-and-streaming
kodiakhq[bot] Jan 6, 2026
1b28474
Merge branch 'main' into add-note-about-redirects-and-streaming
kodiakhq[bot] Jan 6, 2026
f52a245
Merge branch 'main' into add-note-about-redirects-and-streaming
kodiakhq[bot] Jan 6, 2026
8a65f35
Merge branch 'main' into add-note-about-redirects-and-streaming
kodiakhq[bot] Jan 6, 2026
c4ca79e
Merge branch 'main' into add-note-about-redirects-and-streaming
kodiakhq[bot] Jan 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
14 changes: 14 additions & 0 deletions src/routes/solid-start/building-your-application/data-fetching.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,17 @@ const getCurrentUserQuery = query(async (id: string) => {
In this example, the `getCurrentUserQuery` retrieves the session data, and if an authenticated user exists, it gets their information from the database and returns it.
Otherwise, it redirects the user to the login page.
All of these operations are performed completely on the server regardless of how the query is called.

:::caution[Modifying headers after streaming]
Once streaming begins, response headers (including status and cookies) are sent and cannot be changed.
Any header-modifying logic within a server function, such as redirects or APIs like `useSession` that set cookies, must run before streaming starts, or this error will occur:

**"Cannot set headers after they are sent to the client."**

To avoid this, disable streaming for queries that may modify headers by enabling the [`deferStream`](/solid-router/reference/data-apis/create-async#deferstream) option.

```tsx
const user = createAsync(() => getCurrentUserQuery(), { deferStream: true });
```

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
**"Cannot set headers after they are sent to the client."**
To avoid this, disable streaming for queries that may modify headers by enabling the [`deferStream`](/solid-router/reference/data-apis/create-async#deferstream) option.
```tsx
const user = createAsync(() => getCurrentUserQuery(), { deferStream: true });
```
To avoid this, disable streaming for queries that may modify headers by enabling the [`deferStream`](/solid-router/reference/data-apis/create-async#deferstream):
```tsx
const user = createAsync(() => getCurrentUserQuery(), { deferStream: true });

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we should keep the error message. It's a common and vague message, and people might try to search it in the docs.

Copy link
Member

Choose a reason for hiding this comment

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

If that's the case, we should leave it inline.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I updated that line

:::