Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
1b70ef7
removed category pages
Knar33 Mar 12, 2024
d681012
it's metadata
Knar33 Mar 12, 2024
619218d
consolidate into a single quick start guide page
Knar33 Mar 12, 2024
210f3d8
quickstart consistent headers
Knar33 Mar 12, 2024
973dc5a
node/yarn install links
Knar33 Mar 12, 2024
528861a
WSL
Knar33 Mar 12, 2024
e7f99d6
add hyperfy-recipes. Small tweaks
Knar33 Mar 13, 2024
c2a174d
move web3 and secrets to new pages
Knar33 Mar 13, 2024
7a4453b
updates code highlight color for dark mode
Knar33 Mar 13, 2024
1dfd230
directory
Knar33 Mar 14, 2024
18f3d53
app id
Knar33 Mar 14, 2024
78fa3d5
rearrange apps section
Knar33 Mar 14, 2024
2d566a1
quickstart scripts
Knar33 Mar 14, 2024
272847a
uploading
Knar33 Mar 14, 2024
bb17d91
id
Knar33 Mar 14, 2024
d25013a
use-entity
Knar33 Mar 15, 2024
3d8de1f
use-editing
Knar33 Mar 15, 2024
64b1bbe
useFields fixed sample, added color field
Knar33 Mar 15, 2024
a3f3da7
useFields image
Knar33 Mar 15, 2024
bb27558
fix useFile
Knar33 Mar 15, 2024
3662565
useSyncState
Knar33 Mar 15, 2024
e1f5bb7
useWorld
Knar33 Mar 15, 2024
568ac60
hello world
Knar33 Mar 16, 2024
5fffebd
useWorld more examples
Knar33 Mar 16, 2024
d93895b
highlight move
Knar33 Mar 16, 2024
f5c78ac
useEth
Knar33 Mar 16, 2024
ef4bbe2
secrets example
Knar33 Mar 19, 2024
be72f93
deg2rad/rad2deg
Knar33 Mar 19, 2024
2e6a9c4
euler
Knar33 Mar 19, 2024
a23c394
euler docs link
Knar33 Mar 19, 2024
e672d0a
matrix4
Knar33 Mar 19, 2024
7d68737
quaternion
Knar33 Mar 19, 2024
e4756d9
randomint
Knar33 Mar 19, 2024
d4cc7c8
seed
Knar33 Mar 19, 2024
99e1540
vec3
Knar33 Mar 19, 2024
113b97f
console log
Knar33 Mar 19, 2024
e8e04c3
re-ordered util pages in sidebar
Knar33 Mar 19, 2024
94fe04c
avatar
Knar33 Mar 19, 2024
443171e
avatar prop types
Knar33 Mar 19, 2024
0bde1e9
event
Knar33 Mar 19, 2024
a9e4d1b
re-added deleted pages
Knar33 Mar 19, 2024
106a254
added secrets back to dev folder
Knar33 Mar 19, 2024
c2d5aca
restoring some of the old page data
Knar33 Mar 19, 2024
8cf2648
removed code summaries
Knar33 Mar 19, 2024
e30ec05
added in blank index.md files and changed config
Knar33 Mar 19, 2024
9051c41
docasaurus sidebar config
Knar33 Mar 19, 2024
7b64d97
destructibles code
Knar33 Mar 20, 2024
cf3ff69
hide index files from sidebar
Knar33 Mar 20, 2024
b77868e
destructibles app update
Knar33 Mar 20, 2024
cdf1708
balanceOf
Knar33 Mar 20, 2024
e51191c
light
Knar33 Mar 20, 2024
16bcaeb
more destructibles updates
Knar33 Mar 21, 2024
0bad7ae
final code
Knar33 Mar 21, 2024
d400ad8
always have trigger active
Knar33 Mar 21, 2024
0e7f0ed
actual final app code
Knar33 Mar 21, 2024
b18a606
destructibles guide
Knar33 Mar 22, 2024
04ec442
9
Knar33 Mar 22, 2024
af82a55
destructibles guide finished
Knar33 Mar 22, 2024
3d59544
METAMIKE - added files, removed headers
Knar33 Mar 22, 2024
6945aa8
METAMIKE - replaced images
Knar33 Mar 22, 2024
d1484d9
fix hyperlinks
Knar33 Mar 22, 2024
90549f9
METAMIKE - remove orange dots
Knar33 Mar 22, 2024
902cff0
fix comment
Knar33 Mar 22, 2024
9ed47c3
Merge pull request #5 from Knar33/main
madjin Mar 23, 2024
d13fb6f
security: upgrade Docusaurus 2.0.0-beta.21 to 3.9.2
madjin Dec 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/designers/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"position": 120,
"label": "🎨 Designers",
"collapsible": true
}
6 changes: 2 additions & 4 deletions docs/designers/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
---
sidebar_position: 120
---

# 🎨 Designers
sidebar_class_name: hidden
---
5 changes: 5 additions & 0 deletions docs/developers/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"position": 130,
"label": "🖥️ Developers",
"collapsible": true
}
232 changes: 232 additions & 0 deletions docs/developers/_quickstart_consolidated.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
---
sidebar_position: 20
---

# Quick Start

To get started you'll need [NodeJS](https://nodejs.org/en) + [Npm/Yarn](https://classic.yarnpkg.com/lang/en/docs/install/). We recommend using NodeJS `v16.14.2` as this is the version we build and test with. If you are on a Windows operating system you may have trouble install/deploying without having [WSL](https://learn.microsoft.com/en-us/windows/wsl/install) (Windows Subsystem for Linux 1 or 2) installed on your machine. A utility like [nvm](https://github.com/nvm-sh/nvm) allows you to quickly switch between different versions of node.

The easiest way to get started with the SDK is by initializing a new project using `npx`:

```bash
npx hyperfy create quickstart
```

This will create a directory containing the project with a demo app to get you started.

Navigate into the directory and launch the world:

```bash
cd quickstart
npm install
npm run dev
```

Visit `http://localhost:4000` in your browser. You should now be standing in a virtual world running locally on your machine!

Hit `Tab` to open the editor.

Your project comes with a demo app called `Treasure Chest` that you can add to the world. When you walk up to it and click on it, it opens.

Open `apps/treasure-chest/index.js` and change the `OPEN_CLOSE_SPEED` value from `0.5` to `2` and hit save. Your app will be updated and you'll see that the treasure chest now animates slower when opening/closing.

To test multiplayer, just open multiple browser tabs. Each tab will automatially be assigned its own guest account.


## Structure

Once you've created a new project it will look something like this:

```
my-project/
├─ apps/
│ ├─ treasure-chest/
│ │ ├─ assets/ models, images, audio, etc
| | |- src/ raw assets eg .blend
│ │ ├─ app.json app metadata
│ │ ├─ secrets.json app server-side secrets
│ │ ├─ index.js script entrypoint
```

## Apps

Each app lives inside its own folder inside the `/apps` directory. They will be built when code is changed and in the browser you can bring them into the world to test from the editor, opened with the `Tab` key.

Everything added to a world in Hyperfy is an App. It is up to you if you want to create one giant app that holds your entire space or create many little apps that you can compose together and easily make changes in your live world using the editor.

To create another app it's easiest to just duplicate an existing one and edit the `app.json` to give it a new id and title etc. We have created a Github repository containing a collection of [Hyperfy Recipes](https://github.com/hyperfy-io/hyperfy-recipes) demonstrating how to build different apps using the Hyperfy SDK to get you started.

## Assets

All finalized models, sounds, videos or images you reference in your app should be placed in the `assets` folder. These files will be uploaded along with your code.

## Sources

You should store any raw source files like `.blend` and `.psd` in the `src` folder. These files won't be uploaded to Hyperfy but are useful if you want to use `git` and `git-lfs` to version control or share your project with others.

## Scripts

Each app requires a single `index.js` entrypoint. From there you can import any other js files in the app folder including other npm packages you have installed.

Your scripts run on both the server and on each client's browser independently. The server is not a central authority and doesn't automatically synchronize script data between clients. The `hyperfy` package provides utilities for synchronizing data, accessing secrets on the server, and running server-only or client-only code. It also provides a bunch of useful utilities out of the box including `Vector3`, `DEG2RAD`, `tween`, etc. See the API Reference for more info.

## Metadata

The `app.json` file describes the app and its metadata.

```json title='app.json'
{
"id": "fridge",
"name": "Fridge",
"description": "A fridge that opens and closes",
"image": "image.png"
}
```

:::caution

It's important to choose a unique ID for your project, eg by prefixing it with your name or company. It may only contain lowercase alphanumeric characters and hyphens.

:::


## React

Apps in Hyperfy are built using the declarative power of React – But – instead of rendering to the DOM your app is being rendered into an automatic multiplayer virtual world. Instead of using DOM elements like `<div>` and `<p>` you have access to powerful new elements such as `<model>` and `<rigidbody>`.

Everything else is Just React™, with full access to component based design, hooks, context and the entire React and Javascript ecosystem.

Your apps `index.js` file should export a default React component that will be used as the entry point for your app.

The following is a simple app that displays a large field of grass:

<details>
<summary>Click to show code</summary>

```jsx
import React from "react";

export default function Grass() {
return (
<app>
<rigidbody>
<box size={[100, 0.1, 100]} color="green" />
</rigidbody>
</app>
);
}
```
</details>

## Performance

Thanks to React, Hyperfy is able to take full advantage of a virtual dom and only update things that need updating. On top of this, React can schedule complex tasks to happen later at a more optimal time. This is something no other engine can compete with.

One thing we **must** be careful with, is identifying when to jump into imperative code.

A perfect example of this is when animating objects each frame. Instead of thrashing React with state updates, it's best to do this _outside_ of react state:

<details>
<summary>Click to show code</summary>

```jsx
import React, { useRef, useEffect } from 'react'
import { useWorld, Vector3 } from 'hyperfy'

function MovingBox() {
const ref = useRef()
const world = useWorld()

useEffect(() => {
const box = ref.current
const position = new Vector3()
// highlight-start
return world.onUpdate(delta => {
position.y += delta
box.setPosition(position)
})
// highlight-end
}, [])

return (
<box ref={ref}>
)
}
```
</details>

## Sync State

While you are free to use React's `useState` hooks in order to change things only for the current avatar, it's likely you'll want to have some or all of your state synchronized with all clients connected to the world so that everyone sees the same thing.

To do this, export a `getStore` function and then use the `useSyncState` hook to read and write to the distributed store.

The following example shows a cube that changes color when anyone clicks on it. The color change is observed by **everyone** in the world:

<details>
<summary>Click to show code</summary>

```jsx
import React from "react";
// highlight-next-line
import { useSyncState } from "hyperfy";

export default function ColorCube() {
// highlight-next-line
const [color, dispatch] = useSyncState((state) => state.color);
return (
<app>
// highlight-next-line
<box color={color} onPointerDown={() => dispatch("toggle")} />
</app>
);
}

const initialState = {
color: "blue",
};

// highlight-start
export function getStore(state = initialState) {
return {
state,
actions: {
toggle(state) {
state.color = state.color === "blue" ? "red" : "blue";
},
},
};
}
// highlight-end
```
</details>

Synchronized state is inspired by the flux/redux pattern popular on the web, but instead of dispatching events locally they are distributed across all clients and the server.

While it may take a second to get used to we've found that this flow is far more efficient and superior to what most platforms do by syncing the component changes of every entity in the space each time they change. This is the ultimate flex for declarative programming that other 3D engines don't have access to.

## Uploading

Once you're happy with your app and want to use them in your actual world, you can upload them to Hyperfy with a single command.

## Checklist

1. Test your app to make sure it runs well on mobile, desktop and VR devices.
2. Make sure your `app.json` file has the correct metadata that you want.
3. Ensure any files you don't need uploaded are in your `src` folder, not your `assets` folder.

## Upload to Hyperfy

Ensure you are connected to Hyperfy. This will open a hyperfy web page, if you are already connected it will tell you to close your browser window, otherwise it will ask you to connect with WalletConnect or MetaMask:

```bash
npm run connect
```

Now build and upload your app, replacing `<id>` with the ID you specified in your `app.json` file:

```bash
npm run upload <id>
```

Once complete you can go to your live world, hit `Tab` to open the editor, click `Add` and switch to the `Uploads` tab where your uploaded apps will be shown.
5 changes: 5 additions & 0 deletions docs/developers/components/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"position": 100,
"label": "Components",
"collapsible": true
}
2 changes: 1 addition & 1 deletion docs/developers/components/background.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Used to change the background color of a world.

This has no effect if you are using a [<skysphere\>](./skysphere) as it cannot be seen.
This has no effect if you are using a [`<skysphere>`](./skysphere) as it cannot be seen.

## Props

Expand Down
5 changes: 2 additions & 3 deletions docs/developers/components/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
sidebar_position: 100
sidebar_label: Components
---
sidebar_class_name: hidden
---
Loading