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/develop/host-your-website.md
-285Lines changed: 0 additions & 285 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -480,288 +480,3 @@ This works across:
480
480
481
481
You do not need to encode the hash or use any additional tools. `bzz://<hash>` is sufficient.
482
482
483
-
## Client-Side Routing
484
-
485
-
This section explains how to add hash based client side routing to your Swarm hosted site so that you can have clean URLs for each page of your website. See the [routing project in the examples repo](https://github.com/ethersphere/examples/tree/main/routing) for a full working example implementation.
486
-
487
-
### Why Hash Based Client Side Routing?
488
-
489
-
Swarm does not behave like a traditional web server — there is **no server-side routing**, and every route must correspond to a real file inside the site manifest.
490
-
If you try to use typical "clean URLs" like:
491
-
492
-
```
493
-
/about
494
-
/contact
495
-
/dashboard/settings
496
-
```
497
-
498
-
Swarm will look for literal files such as:
499
-
500
-
```
501
-
about
502
-
contact
503
-
dashboard/settings
504
-
```
505
-
506
-
...which obviously don’t exist unless you manually manipulate the manifest.
507
-
This is theoretically possible, but is tricky and complex to do manually, and there is currently not (yet) any tooling to make it easier.
508
-
509
-
### How to Add Routing
510
-
511
-
If you want multiple pages on a Swarm-hosted website, you should use a client-side router. Swarm has no server backend running code and so can’t rewrite paths, so we use **React Router’s `HashRouter`**, which keeps all routing inside the browser.
512
-
513
-
Below is the simplest way to set this up using **create-swarm-app** and then adding your own pages.
514
-
515
-
516
-
#### 1. Create a New Vite + React Project (with `create-swarm-app`)
517
-
518
-
Run:
519
-
520
-
```bash
521
-
npm init swarm-app@latest my-dapp-new vite-tsx
522
-
```
523
-
524
-
This generates a clean project containing:
525
-
526
-
```
527
-
src/
528
-
App.tsx
529
-
index.tsx
530
-
config.ts
531
-
public/
532
-
index.html
533
-
package.json
534
-
```
535
-
536
-
You now have a fully working Vite/React app ready for Swarm uploads.
537
-
538
-
539
-
#### 2. Install React Router
540
-
541
-
Inside the project:
542
-
543
-
```bash
544
-
npm install react-router-dom
545
-
```
546
-
547
-
This gives you client-side navigation capability.
548
-
549
-
550
-
551
-
#### 3. Switch the App to Use Hash-Based Routing
552
-
553
-
Swarm only serves literal files, so `/#/about` is the only reliable way to have “pages.”
554
-
555
-
Replace your `App.tsx` with:
556
-
557
-
```tsx
558
-
import { HashRouter, Routes, Route, Link } from 'react-router-dom'
Copy file name to clipboardExpand all lines: docs/develop/manifests.md
+11-13Lines changed: 11 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,15 @@
1
1
---
2
-
title: Directories & Routing (Manifests)
3
-
id: directories-routing
4
-
sidebar_label: Directories & Routing
2
+
title: Manifests ("Virtual Filesystem")
3
+
id: manifests
4
+
sidebar_label: Manifests ("Virtual Filesystem")
5
5
---
6
6
7
7
import Tabs from '@theme/Tabs';
8
8
import TabItem from '@theme/TabItem';
9
9
10
10
Bee nodes — along with tools used for working with them like `bee-js` and `swarm-cli` — let you upload whole folders of files to Swarm.
11
11
12
-
Swarm doesn’t have a traditional filesystem, but can _act like one_ using **manifests**, which map readable paths (like `/images/cat.jpg`) to immutable Swarm references.
12
+
Swarm doesn’t technically have a filesystem, but can *act like one* using **manifests**, which map readable paths (like `/images/cat.jpg`) to immutable Swarm references.
13
13
14
14
:::info
15
15
The `bee-js`[`MantarayNode` class](https://github.com/ethersphere/bee-js?tab=readme-ov-file#swarm-primitives) is the main way to work with manifests in NodeJS.
@@ -213,13 +213,16 @@ Instead, download files by using the top-level directory manifest and the file
Meanwhile, `"folder/"` has **no file itself**, so its target is zero.
268
271
269
-
## Directories (bee-js)
272
+
## Manipulating Directories
270
273
271
274
In this section we explain how to inspect and modify manifests for non-website directories. You can find the completed [example scripts on GitHub](https://github.com/ethersphere/examples/tree/main/manifests).
272
275
@@ -739,9 +742,4 @@ Now the file appears under:
739
742
740
743
Note that the only new method we used was `node.removeFork()` to remove the entry from the manifest.
0 commit comments