Skip to content

Commit 5b0721f

Browse files
committed
add deferStream: true to auth code example
1 parent e53d4f0 commit 5b0721f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/routes/solid-start/advanced/auth.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,11 @@ const getPrivatePosts = query(async function() {
5050
})
5151

5252
export default function Page() {
53-
const posts = createAsync(() => getPrivatePosts());
53+
const posts = createAsync(() => getPrivatePosts(), { deferStream: true });
5454
}
5555
```
5656

5757
Once the user hits this route, the router will attempt to fetch `getPrivatePosts` data.
5858
If the user is not signed in, `getPrivatePosts` will throw and the router will redirect to the login page.
59+
60+
Setting `{ deferStream: true }` will wait until `getPrivatePosts` resolves before loading the page. Otherwise, opening the page directly will error, because server side redirects cannot occur after an initial response has streamed to the client.

0 commit comments

Comments
 (0)