← Back to Skills Marketplace
urbantech

Ainative Nextjs Sdk

by Toby Morning · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
99
Downloads
0
Stars
1
Active Installs
1
Versions
Install in OpenClaw
/install ainative-nextjs-sdk
Description
Use @ainative/next-sdk to add AI chat to Next.js apps (App Router + Pages Router). Use when (1) Installing @ainative/next-sdk, (2) Setting up a streaming cha...
README (SKILL.md)

@ainative/next-sdk

Server-side AINative client for Next.js with App Router support, streaming chat, and auth middleware.

Install

npm install @ainative/next-sdk

Server Client — Chat Completions

// app/api/chat/route.ts
import { createServerClient } from '@ainative/next-sdk/server';

export async function POST(request: Request) {
  const { messages } = await request.json();

  const client = createServerClient({
    apiKey: process.env.AINATIVE_API_KEY!,
  });

  // Non-streaming
  const result = await client.chat.completions.create({
    model: 'claude-3-5-sonnet-20241022',
    messages,
    max_tokens: 1024,
  });

  return Response.json(result);
}

Streaming Response

// app/api/chat/route.ts
import { createServerClient } from '@ainative/next-sdk/server';

export async function POST(request: Request) {
  const { messages } = await request.json();

  const client = createServerClient({ apiKey: process.env.AINATIVE_API_KEY! });

  const stream = await client.chat.completions.create({
    model: 'claude-3-5-sonnet-20241022',
    messages,
    stream: true,
  });

  return new Response(stream.body, {
    headers: {
      'Content-Type': 'text/event-stream',
      'Cache-Control': 'no-cache',
    },
  });
}

Auth Middleware

// middleware.ts (repo root or src/)
import { createMiddleware } from '@ainative/next-sdk/middleware';

export const middleware = createMiddleware({
  apiKey: process.env.AINATIVE_API_KEY!,
  protectedPaths: ['/dashboard', '/api/protected'],
  loginPath: '/login',
  publicPaths: ['/', '/about', '/api/chat'],
});

export const config = {
  matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
};

Client-Side (App Router)

// app/components/Chat.tsx
'use client';
import { useState } from 'react';

export function Chat() {
  const [messages, setMessages] = useState\x3C{ role: string; content: string }[]>([]);
  const [input, setInput] = useState('');

  const send = async () => {
    const newMessages = [...messages, { role: 'user', content: input }];
    setMessages(newMessages);
    setInput('');

    const res = await fetch('/api/chat', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ messages: newMessages }),
    });

    const data = await res.json();
    setMessages([...newMessages, data.choices[0].message]);
  };

  return (
    \x3Cdiv>
      {messages.map((m, i) => \x3Cp key={i}>\x3Cb>{m.role}:\x3C/b> {m.content}\x3C/p>)}
      \x3Cinput value={input} onChange={e => setInput(e.target.value)} />
      \x3Cbutton onClick={send}>Send\x3C/button>
    \x3C/div>
  );
}

Pages Router (API route)

// pages/api/chat.ts
import type { NextApiRequest, NextApiResponse } from 'next';
import { createServerClient } from '@ainative/next-sdk/server';

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
  const client = createServerClient({ apiKey: process.env.AINATIVE_API_KEY! });

  const result = await client.chat.completions.create({
    model: 'claude-3-5-sonnet-20241022',
    messages: req.body.messages,
  });

  res.json(result);
}

Environment Variables

# .env.local
AINATIVE_API_KEY=ak_your_key

Never expose AINATIVE_API_KEY to the client — only use it in server-side code (route handlers, Server Actions, getServerSideProps).

Exports

import { createServerClient } from '@ainative/next-sdk/server';
import { createMiddleware } from '@ainative/next-sdk/middleware';

References

  • packages/sdks/nextjs/src/server/createServerClient.ts — Server client
  • packages/sdks/nextjs/src/middleware/ — Auth middleware
  • packages/sdks/nextjs/examples/app-router/ — Example app
  • packages/sdks/nextjs/src/index.ts — Package exports
Usage Guidance
This SKILL.md looks like legitimate usage documentation for a Next.js SDK, but the manifest fails to declare the AINATIVE_API_KEY that the examples require. Before installing or wiring this into an app: 1) Verify the package source on npm and the repository (confirm maintainer, stars, release history). 2) Confirm the exact environment variable name and required permission scope for the API key; treat the key as a secret and only set it for server-side usage. 3) Prefer installing from the official npm package (check integrity/versions) rather than blindly copying code from an unknown source. 4) If you are automating skill installation, update the manifest to explicitly declare AINATIVE_API_KEY (or ask the publisher to do so) so tooling and reviewers understand the required credential. 5) Rotate the key and limit its permissions if possible. The main actionable concern is the metadata mismatch — it may be an oversight, but verify before granting or storing secrets.
Capability Analysis
Type: OpenClaw Skill Name: ainative-nextjs-sdk Version: 1.0.0 The skill bundle provides standard documentation and integration examples for the '@ainative/next-sdk' package in Next.js. The code snippets follow best practices, such as keeping API keys server-side and using middleware for route protection, with no signs of malicious intent, data exfiltration, or prompt injection.
Capability Assessment
Purpose & Capability
The SKILL.md describes an @ainative/next-sdk for adding AI chat to Next.js apps which matches the name and description. However, the manifest lists no required environment variables or primary credential while the runtime examples consistently require an AINATIVE_API_KEY. That omission is an inconsistency between claimed metadata and actual usage.
Instruction Scope
The instructions are narrowly scoped to installing and using the Next.js SDK: creating server clients, streaming responses, middleware, and client-side usage. They explicitly warn not to expose the API key to the client and do not instruct reading unrelated files or credentials.
Install Mechanism
This is an instruction-only skill with no install spec and no code files; that reduces surface risk because nothing is written or executed by the skill itself. The SKILL.md recommends 'npm install @ainative/next-sdk' (a normal package install).
Credentials
The SDK examples require an AINATIVE_API_KEY (and show adding it to .env.local), but the skill metadata did not declare any required env vars or a primary credential. Requesting an API key for the service is reasonable for this capability, but the manifest omission is a discrepancy that could hide expected credential use or mislead automation.
Persistence & Privilege
always:false and default agent invocation settings are used. The skill does not request persistent presence or modify other skills. No privileged or permanent agent-level settings are requested.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install ainative-nextjs-sdk
  3. After installation, invoke the skill by name or use /ainative-nextjs-sdk
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Initial release of ainative-nextjs-sdk. - Adds server-side AINative client with Next.js App Router and Pages Router support. - Supports streaming and non-streaming AI chat completions via API routes. - Provides AINative authentication middleware for route protection. - Includes documentation and examples for installation, usage, and environment configuration. - Exposes `createServerClient` and `createMiddleware` for integration.
Metadata
Slug ainative-nextjs-sdk
Version 1.0.0
License MIT-0
All-time Installs 1
Active Installs 1
Total Versions 1
Frequently Asked Questions

What is Ainative Nextjs Sdk?

Use @ainative/next-sdk to add AI chat to Next.js apps (App Router + Pages Router). Use when (1) Installing @ainative/next-sdk, (2) Setting up a streaming cha... It is an AI Agent Skill for Claude Code / OpenClaw, with 99 downloads so far.

How do I install Ainative Nextjs Sdk?

Run "/install ainative-nextjs-sdk" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Ainative Nextjs Sdk free?

Yes, Ainative Nextjs Sdk is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Ainative Nextjs Sdk support?

Ainative Nextjs Sdk is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Ainative Nextjs Sdk?

It is built and maintained by Toby Morning (@urbantech); the current version is v1.0.0.

💬 Comments