Skip to content

Commit b295c43

Browse files
committed
adding some details for creating the first route
1 parent 715ffcb commit b295c43

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed

astro.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ export default defineConfig({
256256
'react',
257257
'react/intro/get-started',
258258
'react/intro/setup-sanity',
259+
'react/intro/first-route',
259260
],
260261
},
261262
{
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
---
2+
title: Your First Route
3+
description:
4+
Learn how to create your first route in Sanity and add content elements
5+
---
6+
7+
import { Aside, Steps } from '@astrojs/starlight/components'
8+
9+
After setting up Sanity CMS for your Vyuh React application, the next step is to
10+
create your first route. Routes in Vyuh are the foundation of your application's
11+
content structure, defining pages and their content organization.
12+
13+
<Aside type="tip">
14+
Make sure you've completed the [Set Up Sanity CMS](/react/intro/setup-sanity)
15+
guide before proceeding.
16+
</Aside>
17+
18+
## Understanding Routes in Vyuh
19+
20+
In Vyuh, a route represents a page in your application. Each route:
21+
22+
- Has a unique path (like `/home` or `/about`)
23+
- Contains regions that organize content
24+
- Can have different layouts
25+
- Holds various content elements like cards, rich-text blocks, and more
26+
27+
## Creating Your First Route
28+
29+
<Steps>
30+
31+
1. **Open your Sanity Studio**
32+
33+
Navigate to your Sanity Studio (typically running at
34+
[http://localhost:3333](http://localhost:3333)) and log in.
35+
36+
2. **Create a new Route document**
37+
38+
In the Sanity Studio sidebar, find the "Content" section and click on
39+
"Route". Then click the "Create new" button.
40+
41+
3. **Configure the Route**
42+
43+
Fill in the basic route information:
44+
45+
- **Title**: Give your route a descriptive name (e.g., "Home Page")
46+
- **Path**: Set the URL path for this route (e.g., `/home`)
47+
48+
4. **Add a Region**
49+
50+
Regions are containers that organize content within your route. Let's add a
51+
"body" region:
52+
53+
- Click the "Add item" button to add a Region
54+
- Choose "+ Create" to create a new Region. This will open up a new panel.
55+
- Set the identifier to "body" and the title to "Body"
56+
- Click "Publish" to create the region
57+
58+
5. **Add Content to the Region**
59+
60+
Now let's add a simple card to our body region:
61+
62+
- Click the "Add Item" button in the body region
63+
- Select "Card" from the content types
64+
- Fill in the card details:
65+
- **Title**: "Hello World"
66+
- **Description**: "My first Vyuh content element"
67+
68+
</Steps>
69+
70+
## Viewing Your Route in Next.js
71+
72+
Now that you've created and published your first route, you can view it in your
73+
Next.js application using the `RouteLoader` component:
74+
75+
```tsx
76+
// In your root page.tsx
77+
import { RouteLoader } from '@vyuh/react-extension-content'
78+
79+
function HomePage() {
80+
return <RouteLoader path="/home" live={true} />
81+
}
82+
```
83+
84+
The `live={true}` property enables real-time updates, so any changes you make in
85+
Sanity Studio will immediately appear in your React application.
86+
87+
<Aside type="note">
88+
89+
Make sure your React application is properly configured with the Vyuh provider
90+
and content plugin as described in the
91+
[Rendering Content](/react/guides/rendering-content) guide.
92+
93+
If you created the repo using the [template workspace](/react/intro/get-started)
94+
that we linked to earlier, then you can just go to the `/home` path on your
95+
address bar, and you should see the page.
96+
97+
![First Page](./images/first-page.png)
98+
99+
</Aside>
100+
101+
## Next Steps
102+
103+
Now that you've created your first route, you can:
104+
105+
1. Add more regions to organize your content
106+
2. Experiment with different content types like portable-text, images, and
107+
groups
108+
3. Try different layouts for your route
109+
4. Create additional routes for other pages in your application
110+
111+
Continue to [Rendering Content with Vyuh React](/react/guides/rendering-content)
112+
to learn more about displaying your Sanity content in your React application.
94.1 KB
Loading

0 commit comments

Comments
 (0)