Skip to content

Commit 349f80b

Browse files
authored
Merge branch 'main' into tobbe-rsc-rsa-extract-fetch
2 parents c1cac80 + 6ee01ce commit 349f80b

File tree

251 files changed

+98969
-65
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

251 files changed

+98969
-65
lines changed

docs/docs/tutorial/chapter0/what-is-redwood.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ You can also prerender pages that contain variables pulled from the URL, like th
6464

6565
This is Redwood's version of static site generation, aka SSG.
6666

67+
#### Accessibility
68+
69+
Redwood includes a couple of components to [aid screen readers](https://redwoodjs.com/docs/accessibility) in properly navigating your app. The `<RouteAnnouncement>` component tells a screen reader to read something aloud, even though it isn't visible in the browser. And the `<RouteFocus>` tells a reader to skip verbose navigation options at the top of a page and get to the content.
70+
6771
### Authentication
6872

6973
The `<PrivateSet>` route limits access to users that are authenticated, but how do they authenticate? Redwood includes integrations to many popular third party authentication hosts (including [Auth0](https://auth0.com/), [Supabase](https://supabase.com/docs/guides/auth) and [Clerk](https://clerk.com/)). You can also [host your own auth](https://redwoodjs.com/docs/auth/dbauth), or write your own [custom authentication](https://redwoodjs.com/docs/auth/custom) option. If going self-hosted, we include login, signup, and reset password pages, as well as the option to include TouchID/FaceID and third party biometric readers!
@@ -76,13 +80,13 @@ The homepage is accessible _without_ being logged in, browsing to `/` will load
7680

7781
Redwood uses GraphQL as the glue between the front- and backends: whenever you want data from the server/database, you're going to retrieve it via GraphQL. Now, we could have just given you raw access to some GraphQL library and let you make those calls yourself. We use [Apollo Client](https://www.apollographql.com/apollo-client) on the frontend and Apollo provides hooks like [useQuery()](https://www.apollographql.com/tutorials/lift-off-part1/10-the-usequery-hook) and [useMutation()](https://www.apollographql.com/tutorials/lift-off-part4/08-the-usemutation-hook) to retrieve and set data, respectively. But Redwood has a much deeper integration.
7882

79-
What if you could have a component that was not only responsible for its own display _but even its own data retrieval_? Meaning everything that component needed in order to display itself could all be self-contained. That includes the code to display while the data is loading, or if something goes wrong. These kinds of uber-components are real, and Redwood calls "cells."
83+
What if you could have a component that was not only responsible for its own display _but even its own data retrieval_? Meaning everything that component needed in order to display itself could all be self-contained. That includes the code to display while the data is loading, or if something goes wrong. These kinds of uber-components are real, and Redwood calls them "cells."
8084

8185
### Cells
8286

8387
A cell is still just a React component (also called a [single file component](https://www.swyx.io/react-sfcs-here)), it just happens to follow a couple of conventions that make it work as described above:
8488

85-
1. The name of the file ends in `Cell"
89+
1. The name of the file ends in "Cell"
8690
2. The file exports several named components, at the very least one named `QUERY` and another named `Success`
8791
3. The file can optionally export several other components, like `Loading`, `Failure` and `Empty`. You can probably guess what those are for!
8892

@@ -138,10 +142,6 @@ You can also directly manipulate the cache to add or remove entries, or even use
138142

139143
If you're familiar with GraphQL then you know that on the backend you define the structure of data that GraphQL queries will return with "resolvers." But GraphQL itself doesn't know anything about talking to databases. How does the raw data in the database make it into those resolvers? That's where our next package comes in.
140144

141-
### Accessibility
142-
143-
Redwood includes a couple of components to [aid screen readers](https://redwoodjs.com/docs/accessibility) in properly navigating your app. The `<RouteAnnouncement>` component tells a screen reader to read something aloud, even though it isn't visible in the browser. And the `<RouteFocus>` tells a reader to skip verbose navigation options at the top of a page and get to the content.
144-
145145
## The Backend
146146

147147
Now we're into the backend code in the `api` directory.
@@ -311,16 +311,16 @@ The entire framework is ([strictly](https://redwoodjs.com/docs/typescript/strict
311311

312312
Redwood's job doesn't end until your application is deployed to the world! That's why we include deploy commands and config to get your app running on the most popular hosts (whether they are serverless or traditional server infrastructure) including:
313313

314-
- [AWS](https://aws.amazon.com/)
315-
- [Vercel](https://vercel.com/)
316-
- [Google Cloud](https://cloud.google.com/)
317-
- [Azure](https://azure.microsoft.com/en-us/)
318-
- [Render](https://render.com/)
319-
- [Flightcontrol](https://www.flightcontrol.dev/)
320-
- [Netlify](https://www.netlify.com/)
314+
- [Coherence (GWC/AWS)](https://www.withcoherence.com/)
315+
- [Flightcontrol.dev (AWS)](https://www.flightcontrol.dev?ref=redwood)
316+
- [Edg.io](https://edg.io)
317+
- [Netlify.com](https://www.netlify.com/)
318+
- [Render.com](https://render.com)
319+
- [Serverless.com](https://serverless.com)
320+
- [Vercel.com](https://vercel.com)
321321
- anywhere [Docker](https://www.docker.com) is accepted
322322

323-
You can even deploy to your own server via SSH commands (we call that our [Baremetal](../../deploy/baremetal.md) deploy).
323+
* You can even deploy to your own server via SSH commands (we call that our [Baremetal](../../deploy/baremetal.md) deploy)!
324324

325325
## Coming Soon
326326

docs/versioned_docs/version-5.x/tutorial/chapter0/what-is-redwood.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -309,16 +309,15 @@ The entire framework is ([strictly](https://redwoodjs.com/docs/typescript/strict
309309

310310
Redwood's job doesn't end until your application is deployed to the world! That's why we include deploy commands and config to get your app running on the most popular hosts (whether they are serverless or traditional server infrastructure) including:
311311

312-
* [AWS](https://aws.amazon.com/)
313-
* [Vercel](https://vercel.com/)
314-
* [Google Cloud](https://cloud.google.com/)
315-
* [Azure](https://azure.microsoft.com/en-us/)
316-
* [Render](https://render.com/)
317-
* [Flightcontrol](https://www.flightcontrol.dev/)
318-
* [Netlify](https://www.netlify.com/)
319-
* anywhere [Docker](https://www.docker.com) is accepted
320-
321-
You can even deploy to your own server via SSH commands (we call that our [Baremetal](../../deploy/baremetal.md) deploy).
312+
- [Coherence (GWC/AWS)](https://www.withcoherence.com/)
313+
- [Flightcontrol.dev (AWS)](https://www.flightcontrol.dev?ref=redwood)
314+
- [Edg.io](https://edg.io)
315+
- [Netlify.com](https://www.netlify.com/)
316+
- [Render.com](https://render.com)
317+
- [Serverless.com](https://serverless.com)
318+
- [Vercel.com](https://vercel.com)
319+
320+
* You can even deploy to your own server via SSH commands (we call that our [Baremetal](../../deploy/baremetal.md) deploy)!
322321

323322
## Coming Soon
324323

docs/versioned_docs/version-6.x/tutorial/chapter0/what-is-redwood.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -309,17 +309,15 @@ The entire framework is ([strictly](https://redwoodjs.com/docs/typescript/strict
309309

310310
Redwood's job doesn't end until your application is deployed to the world! That's why we include deploy commands and config to get your app running on the most popular hosts (whether they are serverless or traditional server infrastructure) including:
311311

312-
* [AWS](https://aws.amazon.com/)
313-
* [Vercel](https://vercel.com/)
314-
* [Google Cloud](https://cloud.google.com/)
315-
* [Azure](https://azure.microsoft.com/en-us/)
316-
* [Render](https://render.com/)
317-
* [Flightcontrol](https://www.flightcontrol.dev/)
318-
* [Netlify](https://www.netlify.com/)
319-
* anywhere [Docker](https://www.docker.com) is accepted
320-
321-
You can even deploy to your own server via SSH commands (we call that our [Baremetal](../../deploy/baremetal.md) deploy).
322-
312+
- [Coherence (GWC/AWS)](https://www.withcoherence.com/)
313+
- [Flightcontrol.dev (AWS)](https://www.flightcontrol.dev?ref=redwood)
314+
- [Edg.io](https://edg.io)
315+
- [Netlify.com](https://www.netlify.com/)
316+
- [Render.com](https://render.com)
317+
- [Serverless.com](https://serverless.com)
318+
- [Vercel.com](https://vercel.com)
319+
320+
* You can even deploy to your own server via SSH commands (we call that our [Baremetal](../../deploy/baremetal.md) deploy)!
323321
## Coming Soon
324322

325323
Redwood is still in active development, and we're working on some [features](https://community.redwoodjs.com/c/experimental-features/25) that are on the cutting edge of the React ecosystem:

docs/versioned_docs/version-7.x/tutorial/chapter0/what-is-redwood.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -309,17 +309,15 @@ The entire framework is ([strictly](https://redwoodjs.com/docs/typescript/strict
309309

310310
Redwood's job doesn't end until your application is deployed to the world! That's why we include deploy commands and config to get your app running on the most popular hosts (whether they are serverless or traditional server infrastructure) including:
311311

312-
* [AWS](https://aws.amazon.com/)
313-
* [Vercel](https://vercel.com/)
314-
* [Google Cloud](https://cloud.google.com/)
315-
* [Azure](https://azure.microsoft.com/en-us/)
316-
* [Render](https://render.com/)
317-
* [Flightcontrol](https://www.flightcontrol.dev/)
318-
* [Netlify](https://www.netlify.com/)
319-
* anywhere [Docker](https://www.docker.com) is accepted
320-
321-
You can even deploy to your own server via SSH commands (we call that our [Baremetal](../../deploy/baremetal.md) deploy).
322-
312+
- [Coherence (GWC/AWS)](https://www.withcoherence.com/)
313+
- [Flightcontrol.dev (AWS)](https://www.flightcontrol.dev?ref=redwood)
314+
- [Edg.io](https://edg.io)
315+
- [Netlify.com](https://www.netlify.com/)
316+
- [Render.com](https://render.com)
317+
- [Serverless.com](https://serverless.com)
318+
- [Vercel.com](https://vercel.com)
319+
320+
* You can even deploy to your own server via SSH commands (we call that our [Baremetal](../../deploy/baremetal.md) deploy)!
323321
## Coming Soon
324322

325323
Redwood is still in active development, and we're working on some [features](https://community.redwoodjs.com/c/experimental-features/25) that are on the cutting edge of the React ecosystem:

docs/versioned_docs/version-8.0/tutorial/chapter0/what-is-redwood.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -311,17 +311,16 @@ The entire framework is ([strictly](https://redwoodjs.com/docs/typescript/strict
311311

312312
Redwood's job doesn't end until your application is deployed to the world! That's why we include deploy commands and config to get your app running on the most popular hosts (whether they are serverless or traditional server infrastructure) including:
313313

314-
- [AWS](https://aws.amazon.com/)
315-
- [Vercel](https://vercel.com/)
316-
- [Google Cloud](https://cloud.google.com/)
317-
- [Azure](https://azure.microsoft.com/en-us/)
318-
- [Render](https://render.com/)
319-
- [Flightcontrol](https://www.flightcontrol.dev/)
320-
- [Netlify](https://www.netlify.com/)
314+
- [Coherence (GWC/AWS)](https://www.withcoherence.com/)
315+
- [Flightcontrol.dev (AWS)](https://www.flightcontrol.dev?ref=redwood)
316+
- [Edg.io](https://edg.io)
317+
- [Netlify.com](https://www.netlify.com/)
318+
- [Render.com](https://render.com)
319+
- [Serverless.com](https://serverless.com)
320+
- [Vercel.com](https://vercel.com)
321321
- anywhere [Docker](https://www.docker.com) is accepted
322322

323-
You can even deploy to your own server via SSH commands (we call that our [Baremetal](../../deploy/baremetal.md) deploy).
324-
323+
* You can even deploy to your own server via SSH commands (we call that our [Baremetal](../../deploy/baremetal.md) deploy)!
325324
## Coming Soon
326325

327326
Redwood is still in active development, and we're working on some [features](https://community.redwoodjs.com/c/experimental-features/25) that are on the cutting edge of the React ecosystem:

docs/versioned_docs/version-8.1/tutorial/chapter0/what-is-redwood.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -311,17 +311,16 @@ The entire framework is ([strictly](https://redwoodjs.com/docs/typescript/strict
311311

312312
Redwood's job doesn't end until your application is deployed to the world! That's why we include deploy commands and config to get your app running on the most popular hosts (whether they are serverless or traditional server infrastructure) including:
313313

314-
- [AWS](https://aws.amazon.com/)
315-
- [Vercel](https://vercel.com/)
316-
- [Google Cloud](https://cloud.google.com/)
317-
- [Azure](https://azure.microsoft.com/en-us/)
318-
- [Render](https://render.com/)
319-
- [Flightcontrol](https://www.flightcontrol.dev/)
320-
- [Netlify](https://www.netlify.com/)
314+
- [Coherence (GWC/AWS)](https://www.withcoherence.com/)
315+
- [Flightcontrol.dev (AWS)](https://www.flightcontrol.dev?ref=redwood)
316+
- [Edg.io](https://edg.io)
317+
- [Netlify.com](https://www.netlify.com/)
318+
- [Render.com](https://render.com)
319+
- [Serverless.com](https://serverless.com)
320+
- [Vercel.com](https://vercel.com)
321321
- anywhere [Docker](https://www.docker.com) is accepted
322322

323-
You can even deploy to your own server via SSH commands (we call that our [Baremetal](../../deploy/baremetal.md) deploy).
324-
323+
* You can even deploy to your own server via SSH commands (we call that our [Baremetal](../../deploy/baremetal.md) deploy)!
325324
## Coming Soon
326325

327326
Redwood is still in active development, and we're working on some [features](https://community.redwoodjs.com/c/experimental-features/25) that are on the cutting edge of the React ecosystem:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use client'
2+
3+
import ReactPlayer from 'react-player'
4+
5+
export default ReactPlayer
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
---
2+
slug: accessibility
3+
description: Accessibility is a core feature that's built-in
4+
---
5+
6+
# Accessibility (aka a11y)
7+
8+
We built Redwood to make building websites more accessible (we write all the config so you don't have to), but Redwood's also built to help you make more accessible websites.
9+
Accessibility shouldn't be a nice-to-have.
10+
It should be a given from the start.
11+
A core feature that's built-in and well-supported.
12+
13+
There's a lot of great tooling out there that'll not only help you build accessible websites, but also help you learn exactly what that means.
14+
15+
> **Does tooling obviate the need for manual testing?**
16+
>
17+
> No—even with all the tooling in the world, manual testing is still important, especially for accessibility.
18+
> But just because tooling doesn't catch everything doesn't mean it's not valuable.
19+
> It'd be much harder to learn what to look for without it.
20+
21+
## Accessible Routing
22+
23+
For single-page applications (SPAs), accessibility starts with the router.
24+
Without a full-page refresh, you just can't be sure that things like announcements and focus are being taken care of the way they're supposed to be.
25+
Here's a great example of [how disorienting SPAs can be to screen-reader users](https://www.youtube.com/watch?v=NKTdNv8JpuM).
26+
On navigation, nothing's announced.
27+
The lack of an announcement isn't just buggy behavior—it's broken.
28+
29+
Normally, the onus would be on you as a developer to announce to screen-reader users that they've navigated somewhere new.
30+
That's a lot to ask—and hard to get right—especially when you're just trying to build your app.
31+
32+
Luckily, if you're writing thoughtful content and marking it up semantically, there's nothing you have to do!
33+
The router automatically announces pages on navigation, and looks for announcements in this order:
34+
35+
1. The `RouteAnnouncement` component
36+
2. The page's `<h1>`
37+
3. `document.title`
38+
4. `location.pathname`
39+
40+
The reason for this order is that announcements should be as specific as possible.
41+
more specific usually means more descriptive, and more descriptive usually means that users can not only orient themselves and navigate through the content, but also find it again.
42+
43+
> If you're not sure if your content is descriptive enough, see the [W3 guidelines](https://www.w3.org/WAI/WCAG21/Techniques/general/G88.html).
44+
45+
Even though Redwood looks for a `RouteAnnouncement` component first, you don't have to have one on every page—it's more than ok for the `<h1>` to be what's announced.
46+
`RouteAnnouncement` is there for when the situation calls for a custom announcement.
47+
48+
### `RouteAnnouncement`
49+
50+
The way `RouteAnnouncement` works is simple: its children will be announced.
51+
Note that this can be something on the page or can be something that's visually hidden using the `visuallyHidden` prop:
52+
53+
```jsx title="web/src/pages/HomePage/HomePage.js"
54+
import { RouteAnnouncement } from '@redwoodjs/router'
55+
56+
const HomePage = () => {
57+
return (
58+
// This will still be visible
59+
<RouteAnnouncement>
60+
<h1>Welcome to my site!</h1>
61+
</RouteAnnouncement>
62+
)
63+
}
64+
65+
export default HomePage
66+
```
67+
68+
```jsx title="web/src/pages/AboutPage/AboutPage.js"
69+
import { RouteAnnouncement } from '@redwoodjs/router'
70+
71+
const AboutPage = () => {
72+
return (
73+
<h1>Welcome to my site!</h1>
74+
// This won't be visible
75+
// highlight-start
76+
<RouteAnnouncement visuallyHidden>
77+
All about me
78+
</RouteAnnouncement>
79+
// highlight-end
80+
)
81+
}
82+
83+
export default AboutPage
84+
```
85+
86+
`visuallyHidden` shouldn't be the first thing you reach for—it's good to maintain parity between your site's visual and audible experiences.
87+
But it's there if you need it.
88+
89+
## Focus
90+
91+
On page change, Redwood Router resets focus to the top of the DOM so that users can navigate through the new page.
92+
While this is the expected behavior (and the behavior you usually want), for some pages—especially those with a lot of navigation—it can be cumbersome for users to have tab through navigation before getting to the main point.
93+
(And that goes for every page change!)
94+
95+
Right now, there's two ways to alleviate this: with skip links or the `RouteFocus` component.
96+
97+
### Skip Links
98+
99+
Since the main content isn't usually the first thing on the page, it's a best practice to provide a shortcut for keyboard and screen-reader users to skip to it.
100+
Skip links do just that, and if you generate a layout using the `--skipLink` option, you'll get one with a skip link:
101+
102+
```
103+
yarn rw g layout main --skipLink
104+
```
105+
106+
```jsx title="web/src/layouts/MainLayout/MainLayout.js"
107+
import { SkipNavLink, SkipNavContent } from '@redwoodjs/router'
108+
import '@redwoodjs/router/skip-nav.css'
109+
110+
const MainLayout = ({ children }) => {
111+
return (
112+
<>
113+
<SkipNavLink />
114+
<nav></nav>
115+
<SkipNavContent />
116+
<main>{children}</main>
117+
</>
118+
)
119+
}
120+
121+
export default MainLayout
122+
```
123+
124+
`SkipNavLink` renders a link that remains hidden till focused and `SkipNavContent` renders a div as the target for the link.
125+
The code for these components comes from Reach UI. For more details, see [Reach UI's docs](https://reach.tech/skip-nav/#reach-skip-nav).
126+
127+
One thing you'll probably want to do is change the URL the skip link sends the user to when activated.
128+
You can do that by changing the `contentId` and `id` props of `SkipNavLink` and `SkipNavContent` respectively:
129+
130+
```jsx
131+
<SkipNavLink contentId="main-content" />
132+
{/* ... */}
133+
<SkipNavContent id="main-content" />
134+
```
135+
136+
If you'd prefer to implement your own skip link, [Ben Myers' blog](https://benmyers.dev/blog/skip-links/) is a great resource, and a great place to read about accessibility in general.
137+
138+
### `RouteFocus`
139+
140+
Sometimes you don't want to just skip the nav, but send a user somewhere.
141+
In this situation, you of course have the foresight that that place is where the user wants to be.
142+
So please use this at your discretion—sending a user to an unexpected location can be worse than sending them back the top.
143+
144+
Having said that, if you know that on a particular page change a user's focus is better off being directed to a particular element, the `RouteFocus` component is what you want:
145+
146+
```jsx title="web/src/pages/ContactPage/ContactPage.js"
147+
// highlight-next-line
148+
import { RouteFocus } from '@redwoodjs/router'
149+
150+
const ContactPage = () => (
151+
<nav>
152+
{/* Way too much nav... */}
153+
</nav>
154+
155+
// The contact form the user actually wants to interact with
156+
// highlight-start
157+
<RouteFocus>
158+
<TextField name="name" />
159+
</RouteFocus>
160+
// highlight-end
161+
)
162+
163+
export default ContactPage
164+
```
165+
166+
`RouteFocus` tells the router to send focus to it's child on page change. In the example above, when the user navigates to the contact page, the name text field on the form is focused—the first field of the form they're here to fill out.
167+
168+
<div class="video-container">
169+
<iframe src="https://www.youtube.com/embed/T1zs77LU68w?t=3240" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture; modestbranding; showinfo=0; fullscreen"></iframe>
170+
</div>

0 commit comments

Comments
 (0)