This repo contains the source for the following examples presented in the Urbit developer documentation:
Example Directory | Example Desk | Interface Type |
---|---|---|
chat-app | %hut | React (JS) |
groups-app | %squad | Sail (Hoon) |
journal-app | %journal | React (JS) |
voting-app | %tally | Sail (Hoon) |
In the documentation that follows, the following shorthands are used:
/path/to/X/
: The path to directory X
on your local machine.example-directory
: The directory of an example in the source tree of this
repository (see the table above).example-desk
: The Urbit desk name of an example in this repository (see
the table above).Each developer example is hosted on ~pocwet
and available for direct install
via Urbit software distribution. To install the example on your ship, enter the
following commands into your ship's webterm
or dojo
:
|install ~pocwet %example-desk
|mount %example-desk
You can then view the files associated with this example on your machine at the
file path /path/to/ship/example-desk
. Please note that this method will only
install Hoon files; to view and experiment with React front-end files, please
read on.
To build one of these example from scratch (which is essential for React development), follow these instructions:
/path/to/repo-source/
./path/to/fake-ship/
.http: web interface live on http://localhost:XYZ
The XYZ
string on this line is port number your ship is using for its HTTP
interface. Save this string for use in the subsequent steps.
dojo
, enter the following commands:
|new-desk %example-desk
|mount %example-desk
rm -rI /path/to/fake-ship/example-desk/*
cp -RL /path/to/repo-source/example-directory/full-desk/* /path/to/fake-ship/example-desk/
dojo
, enter the following commands:
|commit %example-desk
|install our %example-desk
dojo
, run the following command and copy the
result:
+code
This is your fake ship's password, which will be used for authentication from your web browser.
If the example has a React interface, further follow these instructions to set up a locally-hosted front-end interface:
XYZ
is from
step 3):
cd /path/to/repo-source/example-directory/ui/
npm install
echo "VITE_SHIP_URL=http://127.0.0.1:XYZ" >> .env.local
npm run dev
The final command will generate a text digest containing a line of the form:
> Local: http://localhost:ABC/apps/example-desk/
The web address listed here is hosting location for your local React interface. Save this string for use in the subsequent steps.
Once the base infrastructure for an example project is in place, making changes is very simple.
For React front-end development, just make sure to run npm run dev
in a
terminal and to visit the output "local" address for testing; the page will
automatically update as you edit your React files.
For Sail front-end development and back-end development, the process is only slightly more complicated:
/path/to/fake-ship/example-desk/
), you can skip this step. If you're
editing files from the source tree
(i.e. in /path/to/repo-source/example-directory/full-desk/
), you'll need
to copy the files to your ship with the following terminal commands:
rm -rI /path/to/fake-ship/example-desk/*
cp -RL /path/to/repo-source/example-directory/full-desk/* /path/to/fake-ship/example-desk/
dojo
, enter one of the following command
sequences based on your changes:
|commit %example-desk
/sur
file changes, app state
changes, etc.):
|nuke %example-desk
|commit %example-desk