A HarperDB Component for running and developing NestJS apps.
Most Next.js features are supported as we rely on the NestJS Server provided by NestJS to run your application.
[!NOTE] This guide assumes you're already familiar with HarperDb Components. Please review the documentation, or check out the HarperDB Next.js Example for more information.
- Install:
npm install @harperdb/nestjs
- Add to
config.yaml
:
'@harperdb/nestjs':
package: '@harperdb/nestjs'
files: '/*'
- Run your app with HarperDB:
harperdb run nestjs-app
- Within any server side code paths, you can use HarperDB Globals after importing the HarperDB package:
// app/actions.js
'use server';
import('harperdb');
export async function listDogs() {
const dogs = [];
for await (const dog of tables.Dog.search()) {
dogs.push({ id: dog.id, name: dog.name });
}
return dogs;
}
export async function getDog(id) {
return tables.Dog.get(id);
}
// app/dogs/[id]/page.jsx
import { getDog, listDogs } from '@/app/actions';
export async function generateStaticParams() {
const dogs = await listDogs();
return dogs;
}
export default async function Dog({ params }) {
const dog = await getDog(params.id);
return (
<section>
<h1>{dog.name}</h1>
<p>Breed: {dog.get('breed')}</p>
<p>Woof!</p>
</section>
);
}