Skip to content

Commit d021786

Browse files
updates
1 parent fc43f02 commit d021786

File tree

8 files changed

+2894
-9908
lines changed

8 files changed

+2894
-9908
lines changed

.eslintrc.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
save-exact=true

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ The Next.js application can interact with the database through the [Resource API
1111

1212
1. Clone this repo locally
1313
2. Run `npm install`
14-
1. If HarperDB is already installed on your machine (we recommend it be [installed globally](https://docs.harperdb.io/docs/getting-started#installing-a-harperdb-instance)), then run `npm link harperdb`.
1514
3. Run `npm run dev`
1615
4. Open [http://localhost:3000](http://localhost:3000) 🎉
1716

1817
## How does it work?
1918

2019
This example in and of itself is a [HarperDB Component](https://docs.harperdb.io/docs/developers/components), and is reliant on the `@harperdb/nextjs` protocol extension component 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')`).
2120

22-
> [!TIP]
21+
> [!TIP]
2322
> 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.
2423
2524
Based on Next.js best practices, it is recommended to use this in **server actions** so that server _and client_ components can both access the same functions. This example demonstrates this pattern by defining two server actions, `listDogs` and `getDog` (located in [./app/actions.js](./app/actions.js)). These are then used throughout the application, in both [Client](./app/client-component.js) and [Server](./app/dogs/[id]/page.js) components!

app/layout.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ export default function RootLayout({ children }) {
1010
<body style={{ width: '500px', fontFamily: 'sans-serif' }}>
1111
<header>
1212
<nav>
13-
<ul style={{ display: 'flex', gap: '1rem', listStyle: 'none', padding: 0 }}>
13+
<ul
14+
style={{
15+
display: 'flex',
16+
gap: '1rem',
17+
listStyle: 'none',
18+
padding: 0,
19+
}}
20+
>
1421
<li>
1522
<Link href="/">Home</Link>
1623
</li>
@@ -29,7 +36,7 @@ export default function RootLayout({ children }) {
2936

3037
<p>
3138
Dig into the source code here:{' '}
32-
<Link href="https://github.com/HarperDB-Add-Ons/nextjs-example">HarperDB-Add-Ons/nextjs-example</Link>
39+
<Link href="https://github.com/HarperDB/nextjs-example">HarperDB/nextjs-example</Link>
3340
</p>
3441
</section>
3542
{children}

config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
graphqlSchema:
2-
files: '*.graphql'
2+
files: 'schema.graphql'
33
jsResource:
4-
files: './resources.js'
4+
files: 'resources.js'
55
'@harperdb/nextjs':
66
package: '@harperdb/nextjs'
77
files: '/*'

eslint.config.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { FlatCompat } from '@eslint/eslintrc';
2+
3+
const compat = new FlatCompat({
4+
baseDirectory: import.meta.dirname,
5+
});
6+
7+
const eslintConfig = [
8+
...compat.config({
9+
extends: ['next/core-web-vitals', 'prettier'],
10+
}),
11+
];
12+
13+
export default eslintConfig;

0 commit comments

Comments
 (0)