-
Notifications
You must be signed in to change notification settings - Fork 0
feat(templates): add Next.js templates (JavaScript + TypeScript) #123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dawsontoth
merged 15 commits into
main
from
claude/create-harper-nextjs-scaffold-851671
Jul 27, 2026
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
caca1f4
feat(templates): add Next.js templates (JavaScript + TypeScript)
dawsontoth 09dd623
chore(templates): skip Studio build/publish for Next.js templates
dawsontoth d2bb8ff
fix(templates): address Next.js review feedback (age 0, useTransition)
dawsontoth e6f048a
fix(templates): don't import 'harper' in Next.js server code
dawsontoth 56ed077
refactor(templates): slim Next.js templates to a persisted-counter st…
dawsontoth 98355e2
ci(integration): cover Next.js variants in the integration matrix
dawsontoth 742d52e
fix(templates): make Next.js templates install + lint under pnpm and …
dawsontoth 3a8706d
fix(templates): pre-approve pnpm builds via pnpm-workspace.yaml allow…
dawsontoth 1738243
fix(templates): deploy Next.js prebuilt to survive multi-thread clusters
dawsontoth 6bd7435
fix(templates): use Harper's atomic addTo for the counter increment
dawsontoth ff0d37d
fix(templates): mark Next.js templates as SSR in the catalog (ssr: true)
dawsontoth f8e4e35
refactor(templates): drop the prebuilt deploy workaround for Next.js
dawsontoth cb67812
test(nextjs): exercise the increment server action in the runtime smoke
dawsontoth d1a5466
fix(templates): ship Next.js prebuilt — on-cluster build fails (nextj…
dawsontoth e3615e1
docs(ci): describe the prebuilt Next.js smoke flow in integration.yaml
dawsontoth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| # your-project-name-here | ||
|
|
||
| A type-safe [Next.js](https://nextjs.org) app running on Harper via [`@harperfast/nextjs`](https://github.com/HarperFast/nextjs). Your new app is now ready for development! | ||
|
|
||
| Because the app runs _inside_ Harper, server-side code (server actions and server components) reads and writes your database directly through the injected `tables` global — no separate API server and no network round-trip. | ||
|
|
||
| The starter ships one tiny end-to-end example: a counter stored in a Harper table, read by a server component and incremented by a server action. | ||
|
|
||
| ## Installation | ||
|
|
||
| Make sure you have [installed Harper](https://docs.harperdb.io/docs/deployments/install-harper): | ||
|
|
||
| ```sh | ||
| npm install -g harper | ||
| ``` | ||
|
|
||
| ## Development | ||
|
|
||
| Start the app: | ||
|
|
||
| ```sh | ||
| npm run dev | ||
| ``` | ||
|
|
||
| Then open [http://localhost:9926](http://localhost:9926) 🎉 | ||
|
|
||
| Click the button — the count persists in Harper across reloads and restarts. | ||
|
|
||
| ### Define Your Schema | ||
|
|
||
| Your tables live in [`schema.graphql`](./schema.graphql). The starter defines a single `Count` table; add your own `@table` types there, then mirror their shape in [`harper.d.ts`](./harper.d.ts) so your server code stays type-safe. (The `@harperfast/schema-codegen` component can also generate these types for you.) | ||
|
|
||
| ### Access Harper From Server Code | ||
|
|
||
| Harper injects `tables` and `transaction` globals into server-side code, so server actions and server components read and write your database directly — no import needed (their types come from [`harper.d.ts`](./harper.d.ts)). Use an atomic `addTo` inside a `transaction` for writes that stay correct when requests overlap across worker threads and replicated nodes (a read-then-write would lose concurrent increments): | ||
|
|
||
| ```ts | ||
| 'use server'; | ||
|
|
||
| export async function getCount(): Promise<number> { | ||
| const record = await tables.Count.get('count'); | ||
| return record?.value ?? 0; | ||
| } | ||
|
|
||
| export async function increment(): Promise<void> { | ||
| await transaction(async () => { | ||
| const record = await tables.Count.update('count'); | ||
| record.addTo('value', 1); | ||
| }); | ||
| } | ||
| ``` | ||
|
|
||
| > **Don't** add a top-level `import 'harper'` in these modules. It runs during the Next.js production build (when Next collects page data) and conflicts with the running database — use the injected globals instead. | ||
|
|
||
| Put data access in **server actions** (see [`app/actions.ts`](./app/actions.ts)) so that both server _and_ client components can share the same functions. Any action a client can reach is a public endpoint, so add your own authorization checks before shipping mutations that matter. | ||
|
|
||
| ## Deployment | ||
|
|
||
| When you are ready, head to [https://fabric.harper.fast/](https://fabric.harper.fast/), log in to your account, and create a cluster. | ||
|
|
||
| Come back and log your local CLI into your cluster: | ||
|
|
||
| ```sh | ||
| harper login | ||
| ``` | ||
|
|
||
| Then deploy your app: | ||
|
|
||
| ```sh | ||
| npm run deploy | ||
| ``` | ||
|
|
||
| `npm run deploy` runs `next build` locally and ships the prebuilt `.next` output, then Harper serves it — no build runs on the cluster. (Building on the cluster currently fails; see the note in [`config.yaml`](./config.yaml).) | ||
|
|
||
| ## Keep Going! | ||
|
|
||
| For more on building Harper applications, see the [getting started guide](https://docs.harperdb.io/docs). | ||
|
|
||
| For more on Harper Components, see the [Components documentation](https://docs.harperdb.io/docs/reference/components). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| .env |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "version": "0.0.1", | ||
| "configurations": [ | ||
| { | ||
| "name": "harper", | ||
| "runtimeExecutable": "your-package-manager-here", | ||
| "runtimeArgs": ["run", "dev"], | ||
| "port": 9926 | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| CLI_TARGET='your-fabric.harper.fast-cluster-url-here' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| CLI_TARGET='YOUR_FABRIC.HARPER.FAST_CLUSTER_URL_HERE' |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.