|
1 | 1 | --- |
2 | 2 | title: Quickstart |
3 | | -description: Spin up the Hypergraph monorepo locally, including sync server, event workers, and example app. |
| 3 | +description: Create your first Hypergraph-powered application in minutes with TypeSync. |
4 | 4 | version: 0.0.1 |
5 | | -tags: [quickstart] |
| 5 | +tags: [quickstart, typesync] |
6 | 6 | --- |
7 | 7 |
|
8 | | -# 🚀 Quickstart |
| 8 | +# 🚀 Quickstart: Your First Hypergraph App |
| 9 | + |
| 10 | +This guide will walk you through creating a new, fully-functional React application powered by Hypergraph using our scaffolding tool, **TypeSync**. In just a few minutes, you'll have a local development environment up and running. |
| 11 | + |
| 12 | +This approach is perfect for developers who want to quickly build an application on top of Hypergraph without needing to set up the entire monorepo infrastructure. |
9 | 13 |
|
10 | 14 | ## Prerequisites |
11 | 15 |
|
12 | | -- Node >= 18 (tested on 20+) |
13 | | -- pnpm >= 7 (install via `npm install -g pnpm`) |
14 | | -- Bun (optional, but speeds up the dev server — install via `curl -fsSL https://bun.sh/install | bash`) |
| 16 | +- Node.js >= 18 (we recommend v20+) |
| 17 | +- pnpm >= 7 (install with `npm install -g pnpm`) |
15 | 18 |
|
16 | | -Follow these steps to run the **Hypergraph monorepo** on your machine. |
| 19 | +## 1. Get the Hypergraph Toolkit |
17 | 20 |
|
18 | | -## 1. Clone the repository |
| 21 | +First, clone the Hypergraph repository, which contains TypeSync. |
19 | 22 |
|
20 | 23 | ```bash |
21 | 24 | git clone https://github.com/graphprotocol/hypergraph.git |
22 | 25 | cd hypergraph |
23 | 26 | ``` |
24 | 27 |
|
25 | | -## 2. Setup |
26 | | - |
27 | | -Install dependencies and initialize the database: |
| 28 | +Next, install dependencies and build the required packages. This step ensures that TypeSync and all its components are ready to use. |
28 | 29 |
|
29 | 30 | ```bash |
30 | 31 | pnpm install |
31 | | -cd apps/server |
32 | | -cp .env.example .env |
33 | | -pnpm prisma migrate dev |
34 | | -``` |
35 | | - |
36 | | -## 3. Build workspace packages |
37 | | - |
38 | | -Before you run *any* app you must compile the TypeScript workspaces so their `dist/` folders exist: |
39 | | - |
40 | | -```bash |
41 | | -pnpm build # one-off build of every package (hypergraph-react, hypergraph, …) |
| 32 | +pnpm build |
42 | 33 | ``` |
43 | 34 |
|
44 | | -> Pro-tip: while iterating on library code you can use the watch script instead of running a full build each time: |
45 | | -> |
46 | | -> ```bash |
47 | | -> pnpm --filter @graphprotocol/hypergraph-react dev # tsc -w |
48 | | -> ``` |
49 | | -
|
50 | | -After the initial build you can keep a watcher running or rely on the one we start in the next section. |
| 35 | +## 2. Launch TypeSync |
51 | 36 |
|
52 | | -## 4. Development |
| 37 | +TypeSync is a visual tool that helps you define your data schema and then generates a complete starter application based on your design. |
53 | 38 |
|
54 | | -Start a watcher to rebuild packages on change: |
| 39 | +Navigate to the `typesync` app and start its development server: |
55 | 40 |
|
56 | 41 | ```bash |
57 | | -pnpm build --watch |
| 42 | +cd apps/typesync |
| 43 | +pnpm dev |
58 | 44 | ``` |
59 | 45 |
|
60 | | -Then, in separate terminal tabs, run the services: |
| 46 | +This will start the TypeSync server. You can now access the **TypeSync Studio** in your browser at `http://localhost:4000`. |
61 | 47 |
|
62 | | -```bash |
63 | | -# Terminal tab 1: event workers |
64 | | -cd apps/events |
65 | | -pnpm dev |
| 48 | +## 3. Scaffold Your Application |
66 | 49 |
|
67 | | -# Terminal tab 2: sync server |
68 | | -cd apps/server |
69 | | -pnpm dev |
70 | | -``` |
71 | | - |
72 | | -**Note:** Whenever you modify the Prisma schema, regenerate the client with: |
| 50 | +In the TypeSync Studio: |
| 51 | +1. Give your new application a name and a short description. |
| 52 | +2. Use the visual editor to define your data models (we call them "types"). For example, you could create a `Post` type with a `title` (Text) and `content` (Text) properties. |
| 53 | +3. When you're ready, click "Generate App". |
73 | 54 |
|
74 | | -```bash |
75 | | -cd apps/server |
76 | | -pnpm prisma migrate dev |
77 | | -``` |
| 55 | +TypeSync will create a new directory for your application (e.g., `./my-awesome-app`) within the `hypergraph` monorepo, containing all the files and dependencies you need. |
78 | 56 |
|
79 | | -## 5. Run the Next.js example |
| 57 | +## 4. Run Your New App |
80 | 58 |
|
81 | | -Ensure packages are built, then: |
| 59 | +Once your app is generated, open a **new terminal tab**. Navigate into the newly created app directory, install its dependencies, and start the local development server. |
82 | 60 |
|
83 | 61 | ```bash |
84 | | -cd apps/next-example |
| 62 | +# In a new terminal, from the `hypergraph/apps/typesync` directory |
| 63 | +cd ../../my-awesome-app # Adjust the path to match your app's name |
| 64 | +pnpm install |
85 | 65 | pnpm dev |
86 | 66 | ``` |
87 | 67 |
|
88 | | -Visit `http://localhost:3000` to see the example app in action. |
| 68 | +Your new Hypergraph-powered React application will now be running, typically at `http://localhost:5173`. |
89 | 69 |
|
90 | | -> 💡 **Optional:** If you'd rather skip the `pnpm build --watch` process while hacking on `packages/hypergraph-react`, add the package to `transpilePackages` in `apps/next-example/next.config.ts`: |
91 | | -> |
92 | | -> ```ts title="apps/next-example/next.config.ts" |
93 | | -> const nextConfig = { |
94 | | -> transpilePackages: ['@graphprotocol/hypergraph-react'], |
95 | | -> }; |
96 | | -> export default nextConfig; |
97 | | -> ``` |
98 | | -
|
99 | | -## 6. Upgrade dependencies |
100 | | -
|
101 | | -Keep everything up to date with: |
102 | | -
|
103 | | -```bash |
104 | | -pnpm up --interactive --latest -r |
105 | | -``` |
| 70 | +You're all set! You can now start building your application by editing the files in the `src` directory. The generated `src/schema.ts` file contains the Hypergraph schema you defined in TypeSync. |
106 | 71 |
|
107 | 72 | --- |
108 | 73 |
|
|
0 commit comments