Skip to content
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

[rendering-modes] New page! #4667

Merged
merged 40 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
32812b1
new page added
sarah11918 Sep 9, 2023
26d2a08
actually add new page
sarah11918 Sep 9, 2023
79870ec
draft of new page
sarah11918 Sep 9, 2023
37764d0
another pass at the page
sarah11918 Sep 9, 2023
d497df5
incorporated syntax fixes from morinokami in PR 4596
sarah11918 Sep 9, 2023
03f085f
Merge branch 'main' into rendering-modes
sarah11918 Oct 4, 2023
f84a81f
update list of adapters to link to adapter integrations, to match cur…
sarah11918 Oct 4, 2023
54d86dc
edits up to adding an adapter
sarah11918 Oct 16, 2023
6ae328e
Merge branch 'main' into rendering-modes
sarah11918 Oct 17, 2023
ea175d1
second draft
sarah11918 Oct 17, 2023
e7f1548
3rd draft
sarah11918 Oct 19, 2023
fa8eed5
fix broken link
sarah11918 Oct 21, 2023
6b9d466
another editing pass after Talking and Doc'ing feedback!
sarah11918 Oct 21, 2023
eae0f2a
added streaming related recipe
sarah11918 Oct 21, 2023
a4594ba
fix links
sarah11918 Oct 21, 2023
3dac241
adds new page to sidebar w/out removing SSR (for easy comparison)
sarah11918 Oct 21, 2023
489bd41
editing pass at features section
sarah11918 Oct 23, 2023
c8f7169
heading tweak
sarah11918 Oct 23, 2023
1a2321b
removes the old SSR page, netlify redirect
sarah11918 Oct 25, 2023
980031d
basic infra to pivot to two pages for this content
sarah11918 Oct 27, 2023
06cc3a8
Merge branch 'main' into rendering-modes
sarah11918 Oct 27, 2023
34e86bd
remove specific link to configuring individual routes
sarah11918 Oct 27, 2023
ccbe378
Merge branch 'main' into rendering-modes
sarah11918 Oct 27, 2023
539a06c
sidebar updated to match new sections
sarah11918 Oct 27, 2023
e9860ef
Merge branch 'main' into rendering-modes
sarah11918 Oct 27, 2023
210f262
Merge branch 'main' into rendering-modes
sarah11918 Oct 28, 2023
c65b074
Merge branch 'main' into rendering-modes
sarah11918 Oct 28, 2023
2ea1f10
editing pass
sarah11918 Nov 5, 2023
c7065e7
quick rendering modes editing pass
sarah11918 Nov 5, 2023
c49a6eb
more consistent wording
sarah11918 Nov 5, 2023
d785361
i18n true
sarah11918 Nov 5, 2023
fcfa9b7
new title
sarah11918 Nov 5, 2023
869424c
Merge branch 'main' into rendering-modes
sarah11918 Nov 5, 2023
3f25c32
remove empty comment from editing process
sarah11918 Nov 6, 2023
e1cd503
lower case heading
sarah11918 Nov 6, 2023
6d18731
Arsh suggestion
sarah11918 Nov 6, 2023
75a07bd
Merge branch 'main' into rendering-modes
sarah11918 Nov 6, 2023
14393f8
untitle the caution
sarah11918 Nov 6, 2023
34b2a4e
Update src/content/docs/en/guides/server-side-rendering.mdx
sarah11918 Nov 7, 2023
7b590ed
Merge branch 'main' into rendering-modes
sarah11918 Nov 9, 2023
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
54 changes: 54 additions & 0 deletions src/content/docs/en/core-concepts/rendering-modes.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: "Rendering Modes"
i18nReady: true
---
import PackageManagerTabs from '~/components/tabs/PackageManagerTabs.astro';
import RecipeLinks from '~/components/RecipeLinks.astro';

Your Astro project code must be **rendered** to HTML in order to be displayed on the web.

Astro pages, routes, and API endpoints can be either [pre-rendered at build time](#pre-rendered) or [rendered on demand by a server](#on-demand-rendered) when a route is requested. With [Astro islands](/en/concepts/islands/), you can also include some client-side rendering when necessary.

In Astro, most of the processing occurs on the server, instead of in the browser. This generally makes your site or app faster than client-side rendering when viewed on less-powerful devices or on slower internet connections. Server-rendered HTML is fast, SEO friendly, and accessible by default.

## Server `output` modes

You can configure how your pages are rendered in your [`output` configuration](/en/reference/configuration-reference/#output).

### Pre-rendered

The **default rendering mode is __`output: 'static'`__**, which creates the HTML for all your page routes at build time.

In this mode, **your entire site will be pre-rendered** and the server will have all pages built ahead of time and ready to send to the browser. The same HTML document is sent to the browser for every visitor, and a full-site rebuild is required to update the contents of the page. This method is also known as **static site generation (SSG)**.

By default, all Astro projects are configured to be pre-rendered at build time (statically-generated) to provide the most lightweight browser experience. The browser does not need to wait for any HTML to build because the server does not need to generate any pages on demand. Your site is not dependent on the performance of a backend data source, and once built, will remain available to visitors as a static site as long as your server is functioning.

Static sites can include [Astro islands](/en/concepts/islands/) for interactive UI components (or even entire embedded client-side rendered apps!) written in the [UI framework of your choice](/en/core-concepts/framework-components/) in an otherwise static, pre-rendered page.

Astro's [View Transitions API](/en/guides/view-transitions/) are also available in `static` mode for animation and state persistence across page navigation. Static sites can also use [middleware](/en/guides/middleware/) to intercept and transform response data from a request.

:::tip
Astro's default `static` mode is a powerful, modern-feeling choice for content-heavy sites that update infrequently, and display the same page content to all visitors.
:::

### On-demand rendered

Astro's other two output modes can be configured to enable **on-demand rendering of some or all of your pages, routes or API endpoints**:
- __`output: 'server'`__ for highly dynamic sites with most or all on-demand routes.
- __`output: 'hybrid'`__ for mostly static sites with some on-demand routes.

Since they are generated per visit, these routes can be customized for each viewer. For example, a page rendered on demand can show a logged-in user their account information or display freshly updated data without requiring a full-site rebuild. On-demand rendering on the server at request time is also known as **server-side rendering (SSR)**.

[Consider enabling `server` or `hybrid` mode](/en/guides/server-side-rendering/#enable-on-demand-server-rendering) in your Astro project if you need the following:

- **API endpoints**: Create specific pages that function as API endpoints for tasks like database access, authentication, and authorization while keeping sensitive data hidden from the client.

- **Protected pages**: Restrict access to a page based on user privileges, by handling user access on the server.

- **Frequently changing content**: Generate individual pages without requiring a static rebuild of your site. This is useful when the content of a page updates frequently, for example displaying data from an API called dynamically with `fetch()`.

Both `server` and `hybrid` output modes allow you to include [Astro islands](/en/concepts/islands/) for interactivity (or even entire embedded client-side rendered apps!) in your choice of [UI frameworks](/en/core-concepts/framework-components/). With [middleware](/en/guides/middleware/) and Astro's [View Transitions API](/en/guides/view-transitions/) for animations and preserving state across route navigations, even highly interactive apps are possible.

:::tip
On demand server-rendering in Astro provides a true app experience without the JavaScript overhead of a client-side, single-page application.
:::
Loading
Loading