Skip to content
Merged
Changes from 1 commit
Commits
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
4 changes: 3 additions & 1 deletion src/routes/solid-start/advanced/auth.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ const getPrivatePosts = query(async function() {
})

export default function Page() {
const posts = createAsync(() => getPrivatePosts());
const posts = createAsync(() => getPrivatePosts(), { deferStream: true });
}
```

Once the user hits this route, the router will attempt to fetch `getPrivatePosts` data.
If the user is not signed in, `getPrivatePosts` will throw and the router will redirect to the login page.

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.
Comment thread
zhengkyl marked this conversation as resolved.
Outdated