-
Notifications
You must be signed in to change notification settings - Fork 542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs(astro): Add reference to hybrid rendering in Astro #1486
Merged
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2893f38
docs(astro): Add hybrid rendering doc
wobsoriano f9ec61b
Merge branch 'main' into rob/eco-133-add-astro-csr-reference-docs
wobsoriano ae84e16
docs(astro): Specify different rendering modes usage for control comp…
wobsoriano 33cb5f5
Merge branch 'main' into rob/eco-133-add-astro-csr-reference-docs
wobsoriano f027807
docs(astro): Run format
wobsoriano b3c16ed
update copy
alexisintech 6b27e6b
update styling considerations
alexisintech ca30e35
Merge branch 'main' into rob/eco-133-add-astro-csr-reference-docs
alexisintech c28acdd
Remove callout about control components in favor of new dedicated sec…
alexisintech File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
title: Astro Hybrid Rendering | ||
description: Clerk supports Astro in hybrid mode out-of-the-box. | ||
--- | ||
|
||
Astro's on-demand rendering output modes (`server` and `hybrid`) allows you to prerender certain pages while keeping others server-rendered. The Astro SDK supports Astro in hybrid mode out-of-the-box. | ||
|
||
## Server output mode | ||
|
||
When the output mode is set to `server`, pages are server-rendered on request by default. However, you can opt-in to prerendering specific pages. | ||
|
||
### Using Control Components | ||
|
||
When using control components ([`Protect`](/docs/components/protect), [`SignedIn`](/docs/components/control/signed-in), [`SignedOut`](/docs/components/control/signed-out)) in server output mode: | ||
|
||
- By default, these components will be server-rendered. | ||
- If you opt-in to prerendering a page by adding `export const prerender = true`, you need to add the `isStatic={true}` prop to any control components used on that page. This specifies that the component should use the client-side version which relies on the [client nanostores](/docs/references/astro/auth-store). | ||
|
||
```astro {{ filename: 'src/pages/index.astro' }} | ||
--- | ||
export const prerender = true | ||
--- | ||
|
||
<SignedIn isStatic={true}> You are signed in! </SignedIn> | ||
``` | ||
|
||
## Hybrid output mode | ||
|
||
In `hybrid` output mode, pages are prerendered by default. You can opt-out of prerendering for specific pages to make them server-rendered. | ||
|
||
### Using Control Components | ||
|
||
When using control components in `hybrid` output mode: | ||
|
||
- By default, these components will be prerendered. | ||
- If you opt-out of prerendering a page by adding `export const prerender = false`, you need to add the `isStatic={false}` prop to any control components used on that page. This specifies that the component should use the server-side version which relies on the [locals](/docs/references/astro/locals) injected by the middleware. | ||
|
||
```astro {{ filename: 'src/pages/index.astro' }} | ||
--- | ||
export const prerender = false | ||
--- | ||
|
||
<SignedIn isStatic={false}> You are signed in! </SignedIn> | ||
``` | ||
|
||
## Styling considerations | ||
|
||
When using the client-side version of control components (i.e., when `isStatic={true}`), be aware of the wrapper element. For example, the `<SignedIn>` component is wrapped in a custom element. This wrapper may affect your styling, so you might need to adjust your CSS selectors accordingly. | ||
alexisintech marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
For instance, if you want to style the content inside a `<SignedIn>` component, you might need to use a selector like this: | ||
|
||
```astro {{ filename: 'src/pages/index.astro' }} | ||
--- | ||
export const prerender = true | ||
--- | ||
|
||
<SignedIn class="signed-in" isStatic={true}> You are signed in! </SignedIn> | ||
|
||
<style global> | ||
.signed-in { | ||
/* Your styles for the wrapper element */ | ||
} | ||
</style> | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the line "This is required for the integration to work" since our integration will work on any output (
static
,hybrid
,server
) now