### Download Framework-Specific Setup Guide Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-auth-setup.md Use this command to download the full setup documentation for a specific framework, such as Next.js. The downloaded file contains comprehensive instructions. ```bash curl -s -o /tmp/neon-auth-setup.md https://raw.githubusercontent.com/neondatabase-labs/ai-rules/main/references/neon-auth-setup-nextjs.md ``` -------------------------------- ### Start Development Server with Bun Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/evals/add-neon-knowledge-skill/eval-input/README.md Run this command to start the development server for the project. ```bash bun dev ``` -------------------------------- ### Detect Project Framework and Setup Source: https://github.com/neondatabase/ai-rules/blob/main/mcp-prompts/neon-js-setup.md These commands help detect the user's project framework (Next.js, Vite/React, Node.js), check for existing Neon JS installations, identify the package manager, and detect Tailwind CSS configuration. ```bash # Check for Next.js App Router ls app/layout.tsx app/page.tsx ``` ```bash # Check for Vite/React ls vite.config.ts src/main.tsx ``` ```bash # Check for Node.js backend ls package.json | grep -E '(express|fastify|koa)' ``` ```bash # Check if already installed grep '@neondatabase' package.json ``` ```bash # Check for existing setup ls app/api/auth lib/db lib/auth 2>/dev/null ``` ```bash # Detect from lock files ls package-lock.json bun.lockb pnpm-lock.yaml yarn.lock ``` ```bash # Check for Tailwind config ls tailwind.config.js tailwind.config.ts 2>/dev/null ``` -------------------------------- ### Run Development Server with npm Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/evals/neon-drizzle-skill/eval-input/README.md Use this command to start the Next.js development server using npm. Ensure you have npm installed. ```bash npm run dev ``` -------------------------------- ### Using @neondatabase/auth Package Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-js-adapters.md Install and use the `@neondatabase/auth` package for a smaller bundle if database queries are not needed. This example shows client creation, session hook, and authentication methods. ```typescript // Install: npm install @neondatabase/auth import { createAuthClient } from "@neondatabase/auth"; import { BetterAuthReactAdapter } from "@neondatabase/auth/react/adapters"; // First arg is URL, second is config const auth = createAuthClient(import.meta.env.VITE_NEON_AUTH_URL, { adapter: BetterAuthReactAdapter(), }); // React hook const session = auth.useSession(); // Auth methods await auth.signIn.email({ email, password }); await auth.signUp.email({ email, password, name }); await auth.signOut(); ``` -------------------------------- ### Run Development Server with Yarn Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/evals/neon-drizzle-skill/eval-input/README.md Use this command to start the Next.js development server using Yarn. Ensure you have Yarn installed. ```bash yarn dev ``` -------------------------------- ### Run Development Server with pnpm Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/evals/neon-drizzle-skill/eval-input/README.md Use this command to start the Next.js development server using pnpm. Ensure you have pnpm installed. ```bash pnpm dev ``` -------------------------------- ### Knowledge Installation Workflow Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/README.md Defines the workflow for installing Neon best practices into the project's AI knowledge base. This file guides the process of adding `.mdc` files with source attribution. ```json { "name": "install-knowledge", "description": "Installs Neon best practices into your project's AI knowledge base.", "steps": [ { "name": "detect-ai-structure", "description": "Detects the project's AI structure (e.g., .cursor/rules/, CLAUDE.md)." }, { "name": "confirm-installation", "description": "Asks the user for confirmation to install documentation." }, { "name": "copy-files", "description": "Copies relevant .mdc files with source attribution." } ] } ``` -------------------------------- ### Install Dependencies with Bun Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/evals/add-neon-knowledge-skill/eval-input/README.md Use this command to install all project dependencies using Bun. ```bash bun install ``` -------------------------------- ### Install WebSocket Package Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/guides/troubleshooting.md Install the 'ws' package and its types if you need to configure the WebSocket constructor for Neon. ```bash [package-manager] add ws [package-manager] add -D @types/ws ``` -------------------------------- ### Drizzle Kit Usage Examples Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/guides/new-project.md Examples of how to use the added package.json scripts for Drizzle Kit. ```bash npm run db:generate # Generate migrations from schema changes ``` ```bash npm run db:migrate # Apply pending migrations ``` ```bash npm run db:push # Push schema directly (dev only) ``` ```bash npm run db:studio # Open Drizzle Studio ``` -------------------------------- ### Install Neon JS SDK Source: https://github.com/neondatabase/ai-rules/blob/main/mcp-prompts/neon-js-setup.md Install the Neon JS SDK using npm. Replace `npm install` with your detected package manager command (`pnpm add`, `yarn add`, `bun add`) if necessary. ```bash npm install @neondatabase/neon-js ``` -------------------------------- ### Install WebSocket Dependency Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/references/adapters.md Install the 'ws' package and its types when migrating to the WebSocket adapter. ```bash npm add ws @types/ws ``` -------------------------------- ### Fetch Framework-Specific Documentation Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-auth-ui.md Use this command to download the complete documentation for a specific framework, such as Next.js, for detailed UI setup instructions. ```bash curl -s -o /tmp/neon-auth-ui.md https://raw.githubusercontent.com/neondatabase-labs/ai-rules/main/references/neon-auth-ui-nextjs.md ``` -------------------------------- ### HTTP Adapter Setup for Neon Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/guides/troubleshooting.md Use this setup for serverless environments like Vercel or Cloudflare. Ensure your DATABASE_URL is set in your environment variables. ```typescript import { drizzle } from 'drizzle-orm/neon-http'; import { neon } from '@neondatabase/serverless'; const sql = neon(process.env.DATABASE_URL!); export const db = drizzle(sql); ``` -------------------------------- ### Environment File Format Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/guides/new-project.md Example format for the database connection URL in environment files. ```bash DATABASE_URL=postgresql://user:password@host/database?sslmode=require ``` -------------------------------- ### Client Setup - Next.js Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-js-data-api.md Demonstrates how to set up the Neon JS client for use in a Next.js application, including environment variable configuration. ```APIDOC ## Client Setup - Next.js ### Description Set up the Neon JS client for a Next.js application. ### Code ```typescript // lib/db/client.ts import { createClient } from "@neondatabase/neon-js"; import type { Database } from "./database.types"; export const dbClient = createClient({ auth: { url: process.env.NEXT_PUBLIC_NEON_AUTH_URL! }, dataApi: { url: process.env.NEON_DATA_API_URL! }, }); ``` ### Environment Variables ```bash # .env.local NEON_DATA_API_URL=https://ep-xxx.apirest.c-2.us-east-2.aws.neon.build/dbname/rest/v1 ``` ``` -------------------------------- ### Usage Example: Importing Adapters Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/references/adapters.md Demonstrates how to import the appropriate Neon database adapter (HTTP or WebSocket) based on the deployment environment. ```typescript // Vercel Edge Function import { httpDb as db } from '@/db/http'; // Express route import { wsDb as db } from '@/db/ws'; ``` -------------------------------- ### Skill Integration Example 2 Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/add-neon-docs/install-knowledge.md This markdown snippet demonstrates an explicit call to the install-knowledge workflow, setting the SKILL_NAME variable. ```markdown I'll now add reference links to help you in future conversations. ${Read and execute: skills/add-neon-docs/install-knowledge.md} ${Set SKILL_NAME = "neon-drizzle"} ``` -------------------------------- ### Install Neon Serverless Driver Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-serverless/SKILL.md Installs the Neon Serverless Driver using npm. This is the first step to integrate Neon with serverless environments. ```bash npm install @neondatabase/serverless ``` -------------------------------- ### Install Neon Auth Package Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-auth-setup-react-spa.md Install the necessary Neon Auth package and react-router-dom for UI components. ```bash npm install @neondatabase/auth # Or: npm install @neondatabase/neon-js npm install react-router-dom # Required for UI components ``` -------------------------------- ### Skill Integration Example 1 Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/add-neon-docs/install-knowledge.md This markdown snippet shows how to prompt the user to add best practices reference links to their project, triggering the install-knowledge workflow. ```markdown ## Add Best Practices References? Setup is complete! Would you like me to add ${SKILL_NAME} best practices reference links to your project? This helps your AI assistant (me!) remember where to find Neon patterns for future conversations. ${Execute workflow: skills/add-neon-docs/install-knowledge.md with SKILL_NAME="${skill-name}"} ``` -------------------------------- ### Workflow Implementation Example Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/add-neon-docs/SKILL.md This snippet shows a simplified representation of the workflow execution, indicating the received SKILL_NAME parameter and the subsequent execution of the install-knowledge.md script. ```shell Parameter received: SKILL_NAME = ${SKILL_NAME || "not provided - will ask user"} Execute `install-knowledge.md` with the specified SKILL_NAME. ``` -------------------------------- ### Client Setup - Node.js Backend Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-js-data-api.md Provides instructions for configuring the Neon JS client within a Node.js backend environment. ```APIDOC ## Client Setup - Node.js Backend ### Description Set up the Neon JS client for a Node.js backend. ### Code ```typescript import { createClient } from "@neondatabase/neon-js"; const client = createClient({ auth: { url: process.env.NEON_AUTH_URL! }, dataApi: { url: process.env.NEON_DATA_API_URL! }, }); ``` ``` -------------------------------- ### Install Neon Toolkit Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-toolkit/SKILL.md Install the Neon Toolkit package using npm. This command is used for setting up the necessary libraries for managing Neon databases. ```bash npm install @neondatabase/toolkit ``` -------------------------------- ### Check Existing Auth Setup Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-auth/guides/nextjs-setup.md Check for existing authentication route handlers or client configurations to avoid conflicts. ```bash ls app/api/auth # Auth routes exist? ``` ```bash ls lib/auth # Auth client exists? ``` ```bash grep '@neondatabase' package.json # Already installed? ``` -------------------------------- ### Install next-themes for Next.js Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-js-theming.md Install the next-themes package using npm. This is the recommended approach for theming in Next.js applications. ```bash npm install next-themes ``` -------------------------------- ### Install Neon Auth Package Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-auth/guides/nextjs-setup.md Install the Neon Auth package using your project's detected package manager. ```bash [package-manager] add @neondatabase/auth ``` -------------------------------- ### Complete React SPA App.tsx Example Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-auth/guides/react-spa-setup.md This example shows a full implementation of an App.tsx file for a React SPA, including routing for home, authentication, and account pages, along with a navigation bar with sign-in/sign-out functionality. ```tsx import { Routes, Route, useParams } from 'react-router-dom'; import { AuthView, AccountView, UserButton, SignedIn, SignedOut } from '@neondatabase/auth/react/ui'; function AuthPage() { const { pathname } = useParams(); return (
); } function AccountPage() { const { pathname } = useParams(); return (
); } function Navbar() { return ( ); } function HomePage() { return (

Welcome to My App!

You are signed in.

Please sign in to continue.

); } export default function App() { return ( <> } /> } /> } /> ); } ``` -------------------------------- ### Check Existing Setup Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/guides/new-project.md Verify if Drizzle ORM or a schema file already exists in the project. ```bash ls drizzle.config.ts # Already configured? ls src/db/schema.ts # Schema exists? ``` -------------------------------- ### Install HTTP Adapter Dependencies Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/references/adapters.md Install the necessary npm packages for the HTTP adapter. This includes drizzle-orm and the Neon serverless package. ```bash npm add drizzle-orm @neondatabase/serverless npm add -D drizzle-kit ``` -------------------------------- ### Client Setup - React SPA Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-js-data-api.md Illustrates how to initialize the Neon JS client for a React Single Page Application, utilizing environment variables for configuration. ```APIDOC ## Client Setup - React SPA ### Description Set up the Neon JS client for a React SPA. ### Code ```typescript import { createClient } from "@neondatabase/neon-js"; import { BetterAuthReactAdapter } from "@neondatabase/neon-js/auth/react/adapters"; const client = createClient({ auth: { adapter: BetterAuthReactAdapter(), url: import.meta.env.VITE_NEON_AUTH_URL, }, dataApi: { url: import.meta.env.VITE_NEON_DATA_API_URL }, }); ``` ``` -------------------------------- ### Install Neon Auth Package Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-auth-setup-nextjs.md Install the Neon Auth package using npm or yarn. Choose between `@neondatabase/auth` for auth-only or `@neondatabase/neon-js` for auth and database queries. ```bash npm install @neondatabase/auth # Or: npm install @neondatabase/neon-js ``` -------------------------------- ### Server Component Usage Example (Next.js) Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-js-data-api.md Provides an example of how to use the Neon JS client within a Next.js Server Component to fetch and display data. ```APIDOC ## Usage Examples ### Server Component (Next.js) ```typescript // app/posts/page.tsx import { dbClient } from "@/lib/db/client"; export default async function PostsPage() { const { data: posts, error } = await dbClient .from("posts") .select("id, title, created_at, author:users(name)") .order("created_at", { ascending: false }) .limit(10); if (error) return
Error loading posts
; return (
    {posts?.map((post) => (
  • {post.title}

    By {post.author?.name}

  • ))}
); } ``` ``` -------------------------------- ### Install react-router-dom Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-auth/guides/react-spa-setup.md Install `react-router-dom` to enable navigation within your React SPA. This is required for using the auth UI components. ```bash npm install react-router-dom ``` -------------------------------- ### Install Neon Auth Package Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-auth-setup-nodejs.md Install the Neon Auth package using npm. This is the first step to integrate Neon Auth into your Node.js application. ```bash npm install @neondatabase/auth ``` -------------------------------- ### Neon Serverless HTTP Client Setup Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-serverless/SKILL.md Sets up an HTTP client for Neon Serverless, recommended for edge and serverless functions. Ensure the DATABASE_URL environment variable is set. ```typescript import { neon } from '@neondatabase/serverless'; const sql = neon(process.env.DATABASE_URL!); ``` ```typescript const rows = await sql`SELECT * FROM users WHERE id = ${userId}`; ``` -------------------------------- ### Initial Schema Creation SQL Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/references/migrations.md The first migration typically creates all necessary tables, indexes, and constraints. This example defines `users` and `posts` tables. ```sql -- 0000_initial.sql CREATE TABLE users ( id SERIAL PRIMARY KEY, email VARCHAR(255) NOT NULL UNIQUE, name VARCHAR(255) NOT NULL, created_at TIMESTAMP DEFAULT NOW() ); CREATE TABLE posts ( id SERIAL PRIMARY KEY, user_id INTEGER NOT NULL REFERENCES users(id), title TEXT NOT NULL, content TEXT NOT NULL, created_at TIMESTAMP DEFAULT NOW() ); CREATE INDEX posts_user_id_idx ON posts(user_id); ``` -------------------------------- ### Install or Reinstall @neondatabase/auth Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-auth-troubleshooting.md If you encounter 'Cannot find module' errors for `@neondatabase/auth/next`, verify the package is installed or reinstall it using npm. Use `@latest` to ensure you have the most recent version. ```bash # Verify installation npm list @neondatabase/auth # Reinstall if needed npm install @neondatabase/auth@latest # Or for full SDK: npm install @neondatabase/neon-js@latest ``` -------------------------------- ### Install WebSocket Adapter Dependencies Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/references/adapters.md Install the necessary npm packages for the WebSocket adapter. This includes drizzle-orm, the Neon serverless package, and the 'ws' library. ```bash npm add drizzle-orm @neondatabase/serverless ws npm add -D drizzle-kit @types/ws ``` -------------------------------- ### WebSocket Adapter Setup for Neon Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/guides/troubleshooting.md Use this setup for Node.js or long-lived environments. Requires the 'ws' package and configures Neon to use WebSockets. ```typescript import { drizzle } from 'drizzle-orm/neon-serverless'; import { Pool, neonConfig } from '@neondatabase/serverless'; import ws from 'ws'; neonConfig.webSocketConstructor = ws; const pool = new Pool({ connectionString: process.env.DATABASE_URL! }); export const db = drizzle(pool); ``` -------------------------------- ### Supabase Migration Guide - Step 4: Database queries Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-js-adapters.md Database query syntax using the PostgREST API is identical. ```APIDOC ### Step 4: Database queries work the same ```typescript // PostgREST syntax is identical const { data } = await client.from("items").select("*"); await client.from("items").insert({ name: "Item" }); await client.from("items").update({ status: "done" }).eq("id", 1); await client.from("items").delete().eq("id", 1); ``` ``` -------------------------------- ### React SPA Setup with @neondatabase/neon-js Source: https://github.com/neondatabase/ai-rules/blob/main/references/code-generation-rules.md Configure the Neon.js client for a React SPA, including authentication setup with BetterAuthReactAdapter. Requires VITE_NEON_AUTH_URL and VITE_NEON_DATA_API_URL environment variables. ```typescript import { createClient } from "@neondatabase/neon-js"; import { BetterAuthReactAdapter } from "@neondatabase/neon-js/auth/react/adapters"; export const client = createClient({ auth: { adapter: BetterAuthReactAdapter(), url: import.meta.env.VITE_NEON_AUTH_URL, }, dataApi: { url: import.meta.env.VITE_NEON_DATA_API_URL, }, }); export const authClient = client.auth; ``` -------------------------------- ### Install Neon Plugin in Claude Code Source: https://github.com/neondatabase/ai-rules/blob/main/README.md After adding the marketplace, install the Neon plugin itself. This makes the Neon skills available for use within Claude Code. ```bash /plugin install neon-plugin@neon ``` -------------------------------- ### Next.js App Router Server Action Example Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/references/adapters.md Example of creating a user using a Server Action in Next.js App Router, utilizing the HTTP adapter for database interaction. ```typescript // app/actions/users.ts 'use server'; import { db } from '@/db'; // HTTP adapter import { users } from '@/db/schema'; export async function createUser(email: string) { return db.insert(users).values({ email }).returning(); } ``` -------------------------------- ### Correct Single CSS Import Example Source: https://github.com/neondatabase/ai-rules/blob/main/references/code-generation-rules.md Demonstrates the correct way to import Neon UI styles, either with Tailwind CSS or as a standalone CSS import, but not both. ```css /* With Tailwind */ @import 'tailwindcss'; @import '@neondatabase/auth/ui/tailwind'; ``` ```typescript // Without Tailwind import "@neondatabase/auth/ui/css"; ``` -------------------------------- ### Bun WebSocket Adapter Setup Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/references/adapters.md Set up the Neon database client in a Bun environment using the WebSocket adapter. This configuration is suitable for Bun's built-in WebSocket support. ```typescript import { drizzle } from 'drizzle-orm/neon-serverless'; import { Pool } from '@neondatabase/serverless'; const pool = new Pool({ connectionString: process.env.DATABASE_URL! }); export const db = drizzle(pool); ``` -------------------------------- ### HTTP Adapter Setup Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/references/adapters.md Configure the HTTP adapter for Neon database connections, typically used in serverless environments like Vercel Edge Functions. Requires the '@neondatabase/serverless' package. ```typescript // src/db/http.ts import { drizzle } from 'drizzle-orm/neon-http'; import { neon } from '@neondatabase/serverless'; const sql = neon(process.env.DATABASE_URL!); export const httpDb = drizzle(sql); ``` -------------------------------- ### Node.js Backend Client Setup Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-js/guides/setup.md Set up the Neon.js client for a Node.js backend. This includes configuring authentication and data API URLs using environment variables. ```typescript import { createClient } from "@neondatabase/neon-js"; export const client = createClient({ auth: { url: process.env.NEON_AUTH_URL! }, dataApi: { url: process.env.NEON_DATA_API_URL! }, }); // Use in routes await client.auth.signIn.email({ email, password }); const { data } = await client.from("users").select(); ``` ```bash NEON_DATA_API_URL=https://ep-xxx.apirest.c-2.us-east-2.aws.neon.build/dbname/rest/v1 ``` -------------------------------- ### Execute add-neon-docs Skill with SKILL_NAME Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/add-neon-docs/SKILL.md This example demonstrates how to call the add-neon-docs skill from another skill, specifying the SKILL_NAME parameter to target a particular set of Neon documentation. ```markdown Execute the add-neon-docs skill with SKILL_NAME="neon-drizzle" ``` -------------------------------- ### Supabase Migration Guide - Step 3: Auth methods Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-js-adapters.md Auth methods remain the same when migrating to the SupabaseAuthAdapter. ```APIDOC ### Step 3: Auth methods work the same ```typescript // These work identically await client.auth.signInWithPassword({ email, password }); await client.auth.signUp({ email, password }); const { data: { session } } = await client.auth.getSession(); client.auth.onAuthStateChange((event, session) => { /* ... */ }); ``` ``` -------------------------------- ### Supabase Migration Guide - Step 2: Update client creation Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-js-adapters.md Modify your client creation code to use the Neon JS SDK configuration. ```APIDOC ### Step 2: Update client creation ```diff - const client = createClient(SUPABASE_URL, SUPABASE_KEY); + const client = createClient({ + auth: { adapter: SupabaseAuthAdapter(), url: NEON_AUTH_URL }, + dataApi: { url: NEON_DATA_API_URL }, + }); ``` ``` -------------------------------- ### Setup BrowserRouter and Providers for @neondatabase/auth Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-auth-setup-react-spa.md Configure your application's entry point with `BrowserRouter` and `Providers` when using `@neondatabase/auth`, including the UI CSS import if not using Tailwind. ```tsx import { createRoot } from 'react-dom/client'; import { BrowserRouter } from 'react-router-dom'; import '@neondatabase/auth/ui/css'; // if not using Tailwind import App from './App'; import { Providers } from './providers'; createRoot(document.getElementById('root')!).render( ); ``` -------------------------------- ### Setup BrowserRouter and Providers for @neondatabase/neon-js Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-auth-setup-react-spa.md Configure your application's entry point with `BrowserRouter` and `Providers` when using `@neondatabase/neon-js`, including the UI CSS import if not using Tailwind. ```tsx import { createRoot } from 'react-dom/client'; import { BrowserRouter } from 'react-router-dom'; import '@neondatabase/neon-js/ui/css'; // if not using Tailwind import App from './App'; import { Providers } from './providers'; createRoot(document.getElementById('root')!).render( ); ``` -------------------------------- ### Next.js Client Setup Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-js-data-api.md Set up the Neon JS client for use in a Next.js application. Ensure environment variables for authentication and data API URLs are configured. ```typescript import { createClient } from "@neondatabase/neon-js"; import type { Database } from "./database.types"; export const dbClient = createClient({ auth: { url: process.env.NEXT_PUBLIC_NEON_AUTH_URL! }, dataApi: { url: process.env.NEON_DATA_API_URL! }, }); ``` ```bash # .env.local NEON_DATA_API_URL=https://ep-xxx.apirest.c-2.us-east-2.aws.neon.build/dbname/rest/v1 ``` -------------------------------- ### Fetch Posts in Next.js Server Component Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-js/guides/setup.md Example of fetching and displaying posts from the database using the configured `dbClient` in a Next.js server component. ```typescript // app/posts/page.tsx import { dbClient } from "@/lib/db/client"; export default async function PostsPage() { const { data: posts, error } = await dbClient .from("posts") .select("id, title, created_at") .order("created_at", { ascending: false }); if (error) return
Error loading posts
; return (
    {posts?.map((post) => (
  • {post.title}
  • ))}
); } ``` -------------------------------- ### OKLCH Color Format Examples Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-js-theming.md Examples of using the OKLCH color format for defining CSS variables. Supports opacity and provides examples for vivid and neutral colors. ```css --primary: oklch(0.55 0.25 250); /* Vivid blue */ --primary: oklch(0.55 0.25 250 / 50%); /* 50% opacity */ --muted: oklch(0.5 0 0); /* Neutral gray (no chroma) */ ``` -------------------------------- ### Check Neon Auth Package Versions Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-auth-troubleshooting.md Verify the installed versions of the Neon authentication and SDK packages to ensure compatibility. Run this command in your project's root directory. ```bash npm list @neondatabase/auth @neondatabase/neon-js ``` -------------------------------- ### React SPA Client Setup Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-js/guides/setup.md Configure the Neon.js client for a React SPA, including authentication and data API endpoints. Ensure environment variables are set. ```typescript import { createClient } from "@neondatabase/neon-js"; import { BetterAuthReactAdapter } from "@neondatabase/neon-js/auth/react/adapters"; export const client = createClient({ auth: { adapter: BetterAuthReactAdapter(), url: import.meta.env.VITE_NEON_AUTH_URL, }, dataApi: { url: import.meta.env.VITE_NEON_DATA_API_URL, }, }); // Export auth and database separately for convenience export const authClient = client.auth; export const dbClient = client; ``` ```bash VITE_NEON_DATA_API_URL=https://ep-xxx.apirest.c-2.us-east-2.aws.neon.build/dbname/rest/v1 ``` ```typescript import { dbClient } from "./lib/auth-client"; // Use in components const { data, error } = await dbClient.from("items").select(); ``` -------------------------------- ### Copy Drizzle and Serverless Rules for Cursor Source: https://github.com/neondatabase/ai-rules/blob/main/README.md Copy the desired .mdc rule files into the .cursor/rules directory. This example shows how to add Drizzle and Serverless rules for Cursor. ```bash # Example: Copy Drizzle and Serverless rules cp neon-drizzle.mdc .cursor/rules/ cp neon-serverless.mdc .cursor/rules/ ``` -------------------------------- ### Install dotenv-cli Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/references/migrations.md Install `dotenv-cli` as a development dependency to manage environment variables within NPM scripts. ```bash npm add -D dotenv-cli ``` -------------------------------- ### Install Dependencies for Vercel/Edge Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/guides/new-project.md Install Drizzle ORM and related packages for Vercel or Edge environments like Next.js and Vite. ```bash [package-manager] add drizzle-orm @neondatabase/serverless [package-manager] add -D drizzle-kit dotenv @vercel/node ``` -------------------------------- ### Install Dependencies for Node.js Servers Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/guides/new-project.md Install Drizzle ORM and related packages for Node.js server environments like Express and Fastify. ```bash [package-manager] add drizzle-orm @neondatabase/serverless ws [package-manager] add -D drizzle-kit dotenv @types/ws ``` -------------------------------- ### Clone Repository and Navigate Source: https://github.com/neondatabase/ai-rules/blob/main/CONTRIBUTING.md Clone the AI-rules repository and change the directory to the project root. This is the initial step for setting up the development environment. ```bash git clone https://github.com/neondatabase-labs/ai-rules.git cd ai-rules ``` -------------------------------- ### Initialize Neon Auth Client (@neondatabase/auth) Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-auth/guides/react-spa-setup.md Create an auth client instance using `@neondatabase/auth`. Ensure `VITE_NEON_AUTH_URL` is set in your environment variables. The `BetterAuthReactAdapter` must be imported from the correct subpath and called as a function. ```typescript import { createAuthClient } from "@neondatabase/auth"; import { BetterAuthReactAdapter } from "@neondatabase/auth/react/adapters"; export const authClient = createAuthClient( import.meta.env.VITE_NEON_AUTH_URL, { adapter: BetterAuthReactAdapter() } ); ``` -------------------------------- ### Node.js Backend Auth Client Setup Source: https://github.com/neondatabase/ai-rules/blob/main/references/code-generation-rules.md Initialize the auth client for a Node.js backend. The vanilla client can be used directly without needing an adapter. Ensure NEON_AUTH_URL is set in your environment variables. ```typescript import { createAuthClient } from "@neondatabase/auth"; const auth = createAuthClient(process.env.NEON_AUTH_URL!); ``` -------------------------------- ### Initialize Neon Auth Client (@neondatabase/neon-js) Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-auth/guides/react-spa-setup.md Set up the Neon JS client with authentication and data API configurations. The `BetterAuthReactAdapter` must be imported from the correct subpath and called as a function. Ensure `VITE_NEON_AUTH_URL` and `VITE_NEON_DATA_API_URL` are set in your environment variables. ```typescript import { createClient } from "@neondatabase/neon-js"; import { BetterAuthReactAdapter } from "@neondatabase/neon-js/auth/react/adapters"; export const client = createClient({ auth: { adapter: BetterAuthReactAdapter(), url: import.meta.env.VITE_NEON_AUTH_URL, }, dataApi: { url: import.meta.env.VITE_NEON_DATA_API_URL, }, }); // For convenience, export auth separately export const authClient = client.auth; ``` -------------------------------- ### Skill Knowledge Map Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/README.md Metadata for the knowledge installation skill, mapping skill components to knowledge files. This is used to determine which best practices to install for a given skill. ```json { "skillName": "neon-drizzle", "knowledgeFiles": [ "guides/connection-adapters.mdc", "references/schema-patterns.mdc" ] } ``` -------------------------------- ### Run Production Build with Bun Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/evals/add-neon-knowledge-skill/eval-input/README.md Execute this command to run the production build of the project. ```bash bun start ``` -------------------------------- ### Install Local Plugin in Claude Code Source: https://github.com/neondatabase/ai-rules/blob/main/CONTRIBUTING.md Add the local AI-rules plugin to Claude Code's marketplace and then install the neon-plugin. This allows for local testing of your changes. ```bash /plugin marketplace add /absolute/path/to/ai-rules /plugin install neon-plugin@neon ``` -------------------------------- ### Sign Up with Email Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-auth-setup-nodejs.md Use the `signUp.email` method to register a new user with their email and password. Optionally, you can provide the user's name. ```typescript const { data, error } = await auth.signUp.email({ email: "user@example.com", password: "securepassword", name: "John Doe", // Optional }); if (error) { console.error("Sign up failed:", error.message); } ``` -------------------------------- ### Next.js Auth Pages Setup Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-auth/guides/nextjs-setup.md Configure dynamic routes for pre-built Neon Auth pages in your Next.js application. This setup handles various authentication paths automatically. ```typescript import { AuthView } from "@neondatabase/auth/react/ui"; import { authViewPaths } from "@neondatabase/auth/react/ui/server"; export const dynamicParams = false; export function generateStaticParams() { return Object.values(authViewPaths).map((path) => ({ path })); } export default async function AuthPage({ params, }: { params: Promise<{ path: string }>; }) { const { path } = await params; return ; } ``` -------------------------------- ### Check Framework Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/guides/new-project.md Determine the web framework used in the project by searching the package.json file. ```bash grep ""next"" package.json # → Next.js grep ""express"" package.json # → Express grep ""vite"" package.json # → Vite ``` -------------------------------- ### Repository Structure Overview Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/README.md Illustrates the directory structure of the neon-plugin repository, highlighting key files and directories such as plugin metadata, MCP configuration, and skill implementations. ```bash neon-plugin/ ├── .claude-plugin/ │ └── plugin.json # Plugin metadata ├── .mcp.json # MCP server configuration └── skills/ ├── add-neon-docs/ │ ├── SKILL.md │ ├── install-knowledge.md # Workflow for knowledge installation │ └── skill-knowledge-map.json # Metadata for knowledge installation ├── neon-drizzle/ │ ├── SKILL.md │ ├── guides/ # Step-by-step workflow guides │ ├── references/ # Technical reference docs │ ├── scripts/ # Utility scripts │ └── templates/ # Code templates ├── neon-serverless/ │ └── SKILL.md └── neon-toolkit/ └── SKILL.md ``` -------------------------------- ### Install Drizzle Dependencies for Vercel/Edge Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/guides/existing-project.md Install the necessary Drizzle ORM packages for serverless environments like Vercel. This includes drizzle-orm, @neondatabase/serverless, and development dependencies like drizzle-kit and dotenv. ```bash [package-manager] add drizzle-orm @neondatabase/serverless [package-manager] add -D drizzle-kit dotenv ``` -------------------------------- ### Handle GET and POST Requests in Next.js API Route Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-js/guides/setup.md Demonstrates how to use the `dbClient` to handle GET requests for fetching posts and POST requests for inserting new posts within a Next.js API route. ```typescript // app/api/posts/route.ts import { dbClient } from "@/lib/db/client"; import { NextResponse } from "next/server"; export async function GET() { const { data, error } = await dbClient.from("posts").select(); if (error) { return NextResponse.json({ error: error.message }, { status: 500 }); } return NextResponse.json(data); } export async function POST(request: Request) { const body = await request.json(); const { data, error } = await dbClient .from("posts") .insert(body) .select() .single(); if (error) { return NextResponse.json({ error: error.message }, { status: 400 }); } return NextResponse.json(data, { status: 201 }); } ``` -------------------------------- ### Check Environment Variables Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/guides/existing-project.md Verify your environment files for existing DATABASE_URL configurations. Ensure the format is compatible with Neon and adjust if necessary. ```bash ls .env .env.local .env.production grep DATABASE_URL .env* ``` -------------------------------- ### Ordering Results Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-js-data-api.md Examples of how to specify the order of results, including ascending, descending, and ordering by multiple columns. ```typescript // Ascending .order("created_at", { ascending: true }) // Descending .order("created_at", { ascending: false }) // Multiple columns .order("status", { ascending: true }) .order("created_at", { ascending: false }) ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-auth-setup-nodejs.md Set up the NEON_AUTH_URL in your .env file. This URL is essential for the auth client to connect to your Neon Auth instance. ```bash NEON_AUTH_URL=https://ep-xxx.neonauth.c-2.us-east-2.aws.neon.build/dbname/auth ``` -------------------------------- ### URL-encode special characters in password Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/guides/troubleshooting.md Example of encoding special characters in a database password for use in the DATABASE_URL. ```bash # If password is "p@ss&word!" # Encode to: p%40ss%26word%21 ``` -------------------------------- ### Comparison Operators for Filtering Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-js-data-api.md Examples of various comparison operators used for filtering data. These can be chained for complex queries. ```typescript // Equal .eq("status", "active") // Not equal .neq("status", "archived") // Greater than .gt("price", 100) // Greater than or equal .gte("price", 100) // Less than .lt("price", 100) // Less than or equal .lte("price", 100) // Like (pattern matching) .like("name", "%item%") // ILike (case-insensitive) .ilike("name", "%item%") // Is null .is("deleted_at", null) // Is not null .not("deleted_at", "is", null) // In array .in("status", ["active", "pending"]) // Contains (for arrays/JSONB) .contains("tags", ["important"]) ``` -------------------------------- ### Ephemeral Database for Testing Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-toolkit/SKILL.md Example of creating an ephemeral database for use during test runs. The database is automatically deleted after use. ```typescript const db = await neon.createEphemeralDatabase(); // Run tests with fresh database await db.delete(); ``` -------------------------------- ### Snapshot and Restore Rollback Strategy Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/references/migrations.md Use `pg_dump` to create a database backup before migration and `psql` to restore it if issues arise. This is a robust rollback method. ```bash # Before migration: pg_dump $DATABASE_URL > backup.sql # If problems: psql $DATABASE_URL < backup.sql ``` -------------------------------- ### Supabase Migration Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-js-data-api.md Guides users on migrating from Supabase to Neon JS, highlighting the similarities in query syntax and client initialization. ```APIDOC ## Supabase Migration The Neon JS SDK uses the same PostgREST API as Supabase, making migration straightforward: **Before (Supabase):** ```typescript import { createClient } from "@supabase/supabase-js"; const client = createClient(SUPABASE_URL, SUPABASE_KEY); ``` **After (Neon): Using SupabaseAuthAdapter:** ```typescript import { createClient, SupabaseAuthAdapter } from "@neondatabase/neon-js"; const client = createClient({ auth: { adapter: SupabaseAuthAdapter(), url: NEON_AUTH_URL }, dataApi: { url: NEON_DATA_API_URL }, }); ``` **Query syntax remains the same:** ```typescript // Works identically in both await client.auth.signInWithPassword({ email, password }); const { data } = await client.from("items").select(); ``` **For BetterAuth API (default):** ```typescript import { createClient } from "@neondatabase/neon-js"; const client = createClient({ auth: { url: NEON_AUTH_URL }, dataApi: { url: NEON_DATA_API_URL }, }); // Use BetterAuth methods await client.auth.signIn.email({ email, password }); const { data } = await client.from("items").select(); ``` ``` -------------------------------- ### Bash: Test Migrations in Development Environment Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/references/migrations.md Sets the development database URL and runs migrations, followed by running application tests. Ensures migrations are safe before production deployment. ```bash # On dev database export DATABASE_URL=$DEV_DATABASE_URL npm run db:migrate # Test application npm run test # Only then deploy to production ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-auth/guides/nextjs-setup.md Set up the necessary environment variables for Neon Auth, including the base URL and the public-facing URL. ```bash # Neon Auth URL - get this from your Neon dashboard # Format: https://ep-xxx.neonauth.c-2.us-east-2.aws.neon.build/dbname/auth NEON_AUTH_BASE_URL=your-neon-auth-url NEXT_PUBLIC_NEON_AUTH_URL=your-neon-auth-url ``` -------------------------------- ### Client Setup with TypeScript Types Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-js/guides/setup.md Configure the Neon.js client to use generated TypeScript types for enhanced type safety and autocompletion. ```typescript import { createClient } from "@neondatabase/neon-js"; import type { Database } from "./database.types"; export const dbClient = createClient({ auth: { url: process.env.NEXT_PUBLIC_NEON_AUTH_URL! }, dataApi: { url: process.env.NEON_DATA_API_URL! }, }); ``` -------------------------------- ### Example Markdown for Adding References Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/add-neon-docs/SKILL.md This markdown shows the format of references that will be added to your AI documentation file. It includes links to Neon and Drizzle ORM best practices, and serverless connection patterns. ```markdown ## Resources & References - **Neon and Drizzle ORM best practices**: https://raw.githubusercontent.com/neondatabase-labs/ai-rules/main/neon-drizzle.mdc - **Serverless connection patterns**: https://raw.githubusercontent.com/neondatabase-labs/ai-rules/main/neon-serverless.mdc ``` -------------------------------- ### Insert Single Record Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/references/query-patterns.md Use to insert a single record into a table. The `.returning()` method can be used to get the inserted record back. ```typescript import { db } from './db'; import { users } from './db/schema'; const newUser = await db.insert(users) .values({ email: 'user@example.com', name: 'John Doe', }) .returning(); console.log(newUser[0]); // { id: 1, email: '...', name: '...' } ``` -------------------------------- ### Supabase Migration Guide - Step 1: Update imports Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-js-adapters.md Update your import statements when migrating from Supabase to Neon JS SDK. ```APIDOC ### Step 1: Update imports ```diff - import { createClient } from "@supabase/supabase-js"; + import { createClient, SupabaseAuthAdapter } from "@neondatabase/neon-js"; ``` ``` -------------------------------- ### Use Indexed Columns in WHERE Clause Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/references/query-patterns.md Ensure that columns used in WHERE clauses are indexed for faster lookups. This example assumes an index exists on `users.email`. ```typescript // Assuming index on users.email const user = await db.select() .from(users) .where(eq(users.email, 'user@example.com')); // Fast ``` -------------------------------- ### Check Environment Files Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/guides/new-project.md List common environment files present in the project. ```bash ls .env .env.local .env.production ``` -------------------------------- ### Express.js Authentication Endpoints Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-auth-setup-nodejs.md Example implementation of authentication endpoints (signup, login, session, logout) using Express.js and the Neon Auth client. ```typescript import express from "express"; import { createAuthClient } from "@neondatabase/auth"; const app = express(); app.use(express.json()); const auth = createAuthClient(process.env.NEON_AUTH_URL!); // Sign up endpoint app.post("/api/signup", async (req, res) => { const { email, password, name } = req.body; const { data, error } = await auth.signUp.email({ email, password, name }); if (error) { return res.status(400).json({ error: error.message }); } res.json({ user: data.user }); }); // Login endpoint app.post("/api/login", async (req, res) => { const { email, password } = req.body; const { data, error } = await auth.signIn.email({ email, password }); if (error) { return res.status(401).json({ error: error.message }); } res.json({ session: data }); }); // Get session endpoint app.get("/api/session", async (req, res) => { const session = await auth.getSession(); res.json({ session }); }); // Logout endpoint app.post("/api/logout", async (req, res) => { await auth.signOut(); res.json({ success: true }); }); app.listen(3000, () => { console.log("Server running on port 3000"); }); ``` -------------------------------- ### Neon JS SDK Database Query Examples Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-js/guides/setup.md Demonstrates common database operations using the Neon JS SDK, including selecting with filters, selecting with relationships, inserting, updating, and deleting records. Ensure the dbClient is properly initialized before use. ```typescript const { data } = await dbClient .from("items") .select("id, name, status") .eq("status", "active") .order("created_at", { ascending: false }) .limit(10); ``` ```typescript const { data } = await dbClient .from("posts") .select("id, title, author:users(name, email)"); ``` ```typescript const { data, error } = await dbClient .from("items") .insert({ name: "New Item", status: "pending" }) .select() .single(); ``` ```typescript await dbClient .from("items") .update({ status: "completed" }) .eq("id", 1); ``` ```typescript await dbClient .from("items") .delete() .eq("id", 1); ``` -------------------------------- ### Shell Export for DATABASE_URL Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-drizzle/references/migrations.md Set the DATABASE_URL environment variable in your shell before running migration commands. Examples for Bash/Zsh, Fish, and PowerShell are provided. ```bash export DATABASE_URL="$(grep DATABASE_URL .env.local | cut -d '=' -f2)" && \ npm run drizzle-kit migrate ``` ```fish set -x DATABASE_URL (grep DATABASE_URL .env.local | cut -d '=' -f2) npm run drizzle-kit migrate ``` ```powershell $env:DATABASE_URL = (Select-String -Path .env.local -Pattern "DATABASE_URL").Line.Split("=")[1] npm run drizzle-kit migrate ``` -------------------------------- ### Supabase Compatibility Setup Source: https://github.com/neondatabase/ai-rules/blob/main/references/code-generation-rules.md Configure the Neon.js client to use the SupabaseAuthAdapter for Supabase-compatible authentication methods. Requires NEON_AUTH_URL and NEON_DATA_API_URL environment variables. ```typescript import { createClient, SupabaseAuthAdapter } from "@neondatabase/neon-js"; const client = createClient({ auth: { adapter: SupabaseAuthAdapter(), url: process.env.NEON_AUTH_URL!, }, dataApi: { url: process.env.NEON_DATA_API_URL!, }, }); // Use Supabase-style methods await client.auth.signInWithPassword({ email, password }); ``` -------------------------------- ### Check Environment Files Source: https://github.com/neondatabase/ai-rules/blob/main/neon-plugin/skills/neon-auth/guides/nextjs-setup.md Verify the presence of environment variable files like .env or .env.local. ```bash ls .env .env.local ``` -------------------------------- ### Pagination Source: https://github.com/neondatabase/ai-rules/blob/main/references/neon-js-data-api.md Demonstrates how to implement pagination using the .limit() and .range() methods. ```APIDOC ## Pagination ### Description Control the number of results returned and the starting point of the result set. ### Methods #### `.limit(count: number)` Sets the maximum number of rows to return. **Example:** ```typescript .limit(10) ``` #### `.range(from: number, to: number)` Sets the range of rows to return, based on an offset and a limit. **Example:** ```typescript // First 10 items .range(0, 9) // Example for pagination with page and pageSize const page = 1; const pageSize = 10; .range((page - 1) * pageSize, page * pageSize - 1) ``` ```