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: README.md
+21-1Lines changed: 21 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,8 @@ Server Components are an experimental feature and **are not ready for adoption**
23
23
24
24
## Setup
25
25
26
+
You will need to have nodejs >=14.9.0 in order to run this demo. [Node 14 LTS](https://nodejs.org/en/about/releases/) is a good choice!
27
+
26
28
```
27
29
npm install
28
30
npm start
@@ -34,10 +36,24 @@ Then open http://localhost:4000.
34
36
35
37
The app won't work until you set up the database, as described below.
36
38
39
+
<details>
40
+
<summary>Setup with Docker</summary>
41
+
<p>You can also start dev build of the app by using docker-compose.</p>
42
+
<p>Make sure you have docker and docker-compose installed then run:</p>
43
+
<pre><code>docker-compose up</code></pre>
44
+
<h4>Running seed script</h4>
45
+
<p>1. Run containers in the detached mode</p>
46
+
<pre><code>docker-compose up -d</code></pre>
47
+
<p>2. Run seed script</p>
48
+
<pre><code>docker-compose exec notes-app npm run seed</code></pre>
49
+
</details>
50
+
37
51
## DB Setup
38
52
39
53
This demo uses Postgres. First, follow its [installation link](https://wiki.postgresql.org/wiki/Detailed_installation_guides) for your platform.
40
54
55
+
Alternatively, you can check out this [fork](https://github.com/pomber/server-components-demo/) which will let you run the demo app without needing a database. However, you won't be able to execute SQL queries (but fetch should still work).
56
+
41
57
The below example will set up the database for this app, assuming that you have a UNIX-like platform:
42
58
43
59
### Step 1. Create the Database
@@ -96,7 +112,11 @@ This demo is built on top of our Webpack plugin, but this is not how we envision
96
112
- Search for any title. With the search text still in the search input, create a new note with a title matching the search text. What happens?
97
113
- Search while on Slow 3G, observe the inline loading indicator.
98
114
- Switch between two notes back and forth. Observe we don't send new responses next time we switch them again.
99
-
- Uncomment the `fetch('http://localhost:4000/sleep/....')` calls in `NoteServer.js` and/or `NoteList.server.js` to introduce an artificial delay and trigger Suspense.
115
+
- Uncomment the `fetch('http://localhost:4000/sleep/....')` call in `Note.server.js` or `NoteList.server.js` to introduce an artificial delay and trigger Suspense.
116
+
- If you only uncomment it in `Note.server.js`, you'll see the fallback every time you open a note.
117
+
- If you only uncomment it in `NoteList.server.js`, you'll see the list fallback on first page load.
118
+
- If you uncomment it in both, it won't be very interesting because we have nothing new to show until they both respond.
119
+
- Add a new Server Component and place it above the search bar in `App.server.js`. Import `db` from `db.server` and use `db.query()` from it to get the number of notes. Oberserve what happens when you add or delete a note.
0 commit comments