Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Nextly
✓ import { Nextly } from 'nextly'
✗ import Nextly from 'nextly'
Named export, not default. Requires ESM.
defineConfig
✓ import { defineConfig } from 'nextly'
✗ const defineConfig = require('nextly').defineConfig
Named export; CommonJS require may work but not recommended.
NextlyError
✓ import { NextlyError } from 'nextly'
Named export for error handling.
Initializes Nextly with a PostgreSQL adapter, defines a content model, and creates an API route to fetch all posts.
import { Nextly } from 'nextly';
import { adapterPostgres } from '@nextlyhq/adapter-postgres';
const nextly = new Nextly({
adapter: adapterPostgres({
connectionString: process.env.DATABASE_URL ?? ''
})
});
// Define a content model
export const posts = nextly.define('post', {
schema: {
title: 'text',
content: 'text',
published: 'boolean'
}
});
// Create an API route handler
export async function GET(request: Request) {
const allPosts = await posts.findMany();
return new Response(JSON.stringify(allPosts), {
headers: { 'Content-Type': 'application/json' }
});
}
Debug
Known issues
breakingAPI changes between alpha versions: schema definitions and adapter APIs may change without notice.fixPin to a specific alpha version and consult release notes before upgrading.
affects: >=0.0.2-alpha.0 <0.1.0
deprecatedThe 'define' method signature changed in v0.0.2-alpha.15: options object is now required.fixPass options object as second argument to define().
affects: >=0.0.2-alpha.15
gotchaDatabase adapters must be explicitly installed; Nextly does not include them by default.fixInstall one of @nextlyhq/adapter-mysql, @nextlyhq/adapter-sqlite, or @nextlyhq/adapter-postgres.
affects: >=0.0.2-alpha.0
gotchaNode.js version must be >=20.0.0; older versions will fail at runtime.fixUse Node.js 20 or later.
affects: >=0.0.2-alpha.0
gotchaTypeScript strict mode may cause type errors due to incomplete type definitions.fixSet strict: false in tsconfig.json or use type assertions.
affects: >=0.0.2-alpha.0
Errors
Common errors & fixes
Cannot find module '@nextlyhq/adapter-postgres'
The database adapter package is not installed.
fixnpm install @nextlyhq/adapter-postgres
TypeError: nextly.define is not a function
Using an older version where define was a property of the return value of another method, or the import is incorrect.
fixCheck import: import { Nextly } from 'nextly'. Then const posts = nextly.define('post', {...}). Dynamic require of 'nextly' is not supported
Using CommonJS require() with an ESM-only module.
fixUse import statements and set 'type': 'module' in package.json, or use .mjs file extension.
Property 'adapter' is missing in type 'typeof import'
TypeScript expects the adapter to be provided when instantiating Nextly; missing or wrong import.
fixEnsure the adapter package is installed and imported correctly: import { adapterPostgres } from '@nextlyhq/adapter-postgres'. Upgrade
Version history
0.0.2-alpha.20latest on npm
Audit
Dependencies
nextrequiredPeer dependency; Nextly integrates directly with Next.js
@nextlyhq/adapter-mysqloptionalPeer dependency; required MySQL adapter
@nextlyhq/adapter-sqliteoptionalPeer dependency; required SQLite adapter
@nextlyhq/adapter-postgresoptionalPeer dependency; required PostgreSQL adapter