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
+31-3Lines changed: 31 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,16 @@
1
-
# HarperDB Next.js Example
1
+
# Harper Next.js Example
2
2
3
-
This is an example of how to use [`@harperdb/nextjs`](https://github.com/HarperDB/nextjs) to develop a Next.js application with HarperDB.
3
+
This is an example of how to use [`@harperdb/nextjs`](https://github.com/HarperDB/nextjs) to develop a Next.js application with Harper.
4
4
5
5
The Next.js application can interact with the database through the [Resource API](https://docs.harperdb.io/docs/technical-details/reference/resource) directly instead of relying on network operations. This is significantly more efficient and enables a better application development experience.
6
6
7
+
<!--
8
+
TODO: Re-record video with new application steps
7
9
> [!TIP]
8
10
> Watch a walkthrough of this example here: [Next.js on HarperDB | Step-by-Step Guide for Next Level Next.js Performance](https://youtu.be/GqLEwteFJYY)
11
+
-->
12
+
13
+
This example requires the [Harper Basic Data Example](https://github.com/HarperDB/basic-data-example) in order to function. Please follow the instructions in that repo to set up HarperDB with the necessary data before running this example.
9
14
10
15
## Get Started
11
16
@@ -14,9 +19,32 @@ The Next.js application can interact with the database through the [Resource API
14
19
3. Run `npm run dev`
15
20
4. Open [http://localhost:9926](http://localhost:9926) 🎉
16
21
22
+
### Remote Deployment
23
+
24
+
The easiest way to demonstrate this application remotely is to use the `prebuilt: true` option and the [Harper CLI](https://docs.harperdb.io/docs/deployments/harper-cli#operations-api-through-the-cli).
25
+
26
+
1. Locally or in a CI environment, load the necessary data ([Harper Basic Data Example](https://github.com/HarperDB/basic-data-example))
27
+
2. Create a build using `npm run build`
28
+
3. Modify `config.yaml` to include `prebuilt: true` under the `@harperdb/nextjs` component
29
+
5. Then deploy the prebuilt application using the Harper CLI:
30
+
31
+
```bash
32
+
harperdb deploy \
33
+
target="<operations api url>" \
34
+
username="<username>" \
35
+
password='<password>' \
36
+
project=nextjs-example \
37
+
package=HarperDB/nextjs-example \
38
+
skip_node_modules=false \
39
+
replicated=true \
40
+
restart=true
41
+
```
42
+
43
+
Check out the included [build and deploy workflow](./.github/workflows/deploy.yml) for an example of how to automate this process.
44
+
17
45
## How does it work?
18
46
19
-
This example in and of itself is a [HarperDB Component](https://docs.harperdb.io/docs/developers/components), and is reliant on the `@harperdb/nextjs` extension in order to access to the [HarperDB Globals](https://docs.harperdb.io/docs/technical-details/reference/globals). The globals are only available on server-side code paths such as [server actions](https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations) and [server components](https://nextjs.org/docs/app/building-your-application/rendering/server-components). Any code paths using HarperDB globals must first import the `harperdb` package (i.e. `import('harperdb')`).
47
+
This example in and of itself is a [HarperDB Component](https://docs.harperdb.io/docs/developers/components), and is reliant on the `@harperdb/nextjs` extension in order to access the [Harper Resource API](https://docs.harperdb.io/docs/technical-details/reference/resources). The globals are only available on server-side code paths such as [server actions](https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations) and [server components](https://nextjs.org/docs/app/building-your-application/rendering/server-components). Any code paths using HarperDB globals must first import the `harperdb` package (i.e. `import('harperdb')`).
20
48
21
49
> [!TIP]
22
50
> Use the `harperdb-nextjs` CLI (part of the `@harperdb/nextjs` package) to replace the Next.js CLI. For example, `next dev` becomes `harperdb-nextjs dev`. This CLI handles running HarperDB and providing sensible configuration values for the `@harperdb/nextjs` component.
0 commit comments