You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guides/building_your_first_solid_app_with_ldo_and_react.md
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
-
# **Guide to Building Your First Solid App with LDO & React**
1
+
# Building Your First Solid App with LDO & React
2
2
3
3
Welcome to Solid! The ecosystem has dozens of excellent tools to help you build your first application. This guide provides a clear, step-by-step path using one popular and powerful combination: **React** for the user interface and **Linked Data Objects (LDO)** to handle data.
4
4
5
-
## **What is Solid?**
5
+
## What is Solid?
6
6
7
7
The Solid ecosystem is built on a simple but powerful idea: separating applications from the data they create. This gives users control over their own information. It consists of three main parts:
8
8
@@ -12,7 +12,7 @@ The Solid ecosystem is built on a simple but powerful idea: separating applicati
12
12
13
13
This model means you can use multiple apps to manage the same data, and you can switch apps without losing your information.
14
14
15
-
## **What is Linked Data and LDO?**
15
+
## What is Linked Data and LDO?
16
16
17
17
To make sure different apps can understand the same data, Solid uses a standard called the **Resource Description Framework (RDF)**. RDF, often called "Linked Data," is a flexible way to describe things and the relationships between them.
18
18
@@ -22,7 +22,7 @@ LDO uses **ShEx (Shape Expressions)** to define the "shape" of your data. Think
22
22
23
23
In this tutorial, we'll build a simple micro-blogging web app that allows you to write notes and upload photos to your Solid Pod.
24
24
25
-
## **1. Getting Your Solid Identity and Pod**
25
+
## 1. Getting Your Solid Identity and Pod
26
26
27
27
Before you can build an app, you need a place to store your data. We'll get you set up with a free Solid Identity and Pod from solidcommunity.net.
28
28
@@ -31,7 +31,7 @@ Before you can build an app, you need a place to store your data. We'll get you
31
31
32
32
That's it! You now have a Solid Identity to log in with and a Pod to store your data.
33
33
34
-
## **2. Setting Up Your React Project**
34
+
## 2. Setting Up Your React Project
35
35
36
36
This guide assumes you are familiar with React. Let's initialize a new project using Vite, a modern and fast build tool. Since LDO works best with TypeScript, we'll use the TypeScript template.
Now, try logging in. You'll be redirected to solidcommunity.net, and after you approve the application, you'll be sent back to your app, now in a logged-in state.
254
254
255
-
## **5. Defining Data Shapes with ShEx**
255
+
## 5. Defining Data Shapes with ShEx
256
256
257
257
Before we can read or write data, we need to tell LDO what our data looks like. We do this using **ShEx**. Let's set up our project for shapes.
258
258
@@ -297,7 +297,7 @@ npm run build:ldo
297
297
298
298
This command reads your .shex files and generates corresponding code in the .ldo folder, which we'll use in the next step.
299
299
300
-
## **6. Fetching and Displaying Profile Data**
300
+
## 6. Fetching and Displaying Profile Data
301
301
302
302
Let's make our header more personal by displaying the user's name instead of their WebID. We can do this by fetching their profile data from their Pod.
### **How useResource and useSubject Work Together**
349
+
### How useResource and useSubject Work Together
350
350
351
351
This code introduces two fundamental LDO hooks that are important to understand:
352
352
@@ -357,11 +357,11 @@ This separation is powerful. You can load multiple resources (e.g., a profile, a
357
357
358
358
Refresh your app, and you should now see your name in the header after logging in!
359
359
360
-
## **7. Creating and Storing Posts**
360
+
## 7. Creating and Storing Posts
361
361
362
362
Now for the core of our app: creating and saving blog posts.
363
363
364
-
### **Defining the Post Shape**
364
+
### Defining the Post Shape
365
365
366
366
First, we need a ShEx shape for our posts. Create a new file at **src/.shapes/post.shex** and add the following:
367
367
@@ -399,7 +399,7 @@ Run the build command again to generate the typings for our new shape:
399
399
npmrunbuild:ldo
400
400
```
401
401
402
-
### **Finding Where to Save Data**
402
+
### Finding Where to Save Data
403
403
404
404
A common question in Solid is: "Where do I save my app's data?" The best practice is to create a dedicated folder for your app inside the user's Pod. We can find the root of their storage space using the sp:storage property from their profile.
405
405
@@ -462,7 +462,7 @@ In this useEffect, we:
462
462
463
463
We also started logic to render posts. mainContainer.children() gets a list of all items in our app's folder. We then filter for just the containers (since each post will be in its own container) and map over them to render a Post component for each one.
464
464
465
-
### **Creating a New Post**
465
+
### Creating a New Post
466
466
467
467
Now let's wire up the **src/MakePost.tsx** component to actually create data.
468
468
@@ -549,7 +549,7 @@ This is the most complex step, so let's break it down:
549
549
3. **Create Structured Data:** We define where our structured data will live (index.ttl). Then, createData(PostShapeShapeType, ...) gives us a special LDO object (post) that conforms to our PostShape. We can then set its properties (articleBody, uploadDate, image) like a normal object.
550
550
4. **Commit Data:** commitData(post) takes our local changes and sends them to the Solid Pod, creating the index.ttl file with the correct RDF data.
551
551
552
-
## **8. Displaying the Post Content**
552
+
## 8. Displaying the Post Content
553
553
554
554
Finally, let's update **src/Post.tsx** to fetch and display the data for each post.
555
555
@@ -608,7 +608,7 @@ A key detail is how we handle images. Most data in a Pod is private. If we simpl
608
608
609
609
We've also added a delete button that simply deletes the entire container for the post.
610
610
611
-
## **9. Building and Deploying Your App**
611
+
## 9. Building and Deploying Your App
612
612
613
613
Congratulations! You've built a fully functional, decentralized Solid application. To deploy it, you first need to create a production build.
Copy file name to clipboardExpand all lines: docs/guides/solid_nextjs_ldo_demo_application.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# Solid + Next.js + LDO: Demo Application Guide
1
+
# Solid + Next.js + LDO: Demo Application
2
2
3
3
This is a tutorial on how to create a Solid Application using [Next.js](https://nextjs.org/), [LDO](https://ldo.js.org/latest/) and [ACP](https://solidproject.org/TR/acp).
0 commit comments