Build a Next.js App
Augur works with any Next.js application: e-commerce storefronts, customer dashboards, sales rep portals, warehouse tools or internal admin panels. This page calls the SDK directly from server components; for a full storefront on the augur packages (proxy, hooks, components), start with the packages' getting started.
Setup
Follow Getting Started to install the SDK and configure credentials, then create a shared API client:
// lib/augur.ts
import { AugurAPI } from "@simpleapps-com/augur-api";
export const api = new AugurAPI({
siteId: process.env.AUGUR_SITE_ID!,
bearerToken: process.env.AUGUR_JWT!,
});Responses are { data, status, message, … }; fields are camelCase.
E-Commerce: Product Catalog
// app/products/page.tsx
import { api } from "@/lib/augur";
export default async function ProductsPage() {
const response = await api.items.invMast.list({ limit: 25, edgeCache: "5m" });
return (
<ul>
{response.data.map((item) => (
<li key={item.invMastUid}>
{item.itemId} — {item.itemDesc}
</li>
))}
</ul>
);
}E-Commerce: Search
// app/search/page.tsx
import { api } from "@/lib/augur";
export default async function SearchPage({ searchParams }: { searchParams: Promise<{ q?: string }> }) {
const { q } = await searchParams;
if (!q) return <p>Enter a search term</p>;
const results = await api.openSearch.itemSearch.list({ q, searchType: "query", size: 20 });
return (
<ul>
{results.data.items.map((item) => (
<li key={item.invMastUid}>{item.itemDesc}</li>
))}
</ul>
);
}More in the search guide.
E-Commerce: Cart and Checkout
// Add to cart
await api.commerce.cartLine.add.create(cartHdrUid, [{ invMastUid: 12345, quantity: 2, unitOfMeasure: "EA" }]);
// Create a checkout from the order payload (header and lines)
const checkout = await api.commerce.checkout.create({ oeHdr: header, oeLine: lines });
// Validate, then submit to P21
await api.commerce.checkout.validate.update(checkout.data.checkoutUid);
await api.commerce.checkout.activate.update(checkout.data.checkoutUid);augur-utils' buildCheckoutPayload builds the header and lines from cart data; the checkout guide covers the whole flow.
Dashboard: Customer Overview
// app/dashboard/page.tsx
import { redirect } from "next/navigation";
import { resolveAddressId } from "@simpleapps-com/augur-utils";
import { api } from "@/lib/augur";
export default async function DashboardPage() {
// A session carries "no customer" as "" or "0": resolve it, never Number() it
const customerId = resolveAddressId(await customerIdFromSession()); // your session lookup
if (customerId === null) redirect("/login");
const orders = await api.customers.customer.orders.list(customerId, { limit: 10 });
const invoices = await api.customers.customer.invoices.list(customerId, { limit: 10 });
return (
<div>
<h1>Dashboard</h1>
<section>
<h2>Recent Orders</h2>
<ul>
{orders.data.map((order) => (
<li key={order.orderNo}>#{order.orderNo}</li>
))}
</ul>
</section>
<section>
<h2>Invoices</h2>
<ul>
{invoices.data.map((inv) => (
<li key={inv.invoiceNo}>#{inv.invoiceNo}</li>
))}
</ul>
</section>
</div>
);
}The SDK refuses a customerId that is not a usable P21 id ("", "0", 0) with a ValidationError before any request, so resolve the session's value first and decide what a visitor without a customer sees.
Portal: Sales Rep View
// app/rep/[repId]/page.tsx
import { api } from "@/lib/augur";
export default async function RepPage({ params }: { params: Promise<{ repId: string }> }) {
const { repId } = await params;
// Orders assigned to this sales rep
const orders = await api.orders.oeHdrSalesrep.list({ salesrepId: repId, limit: 25 });
return (
<div>
<h1>My Orders</h1>
<ul>
{orders.data.map((order) => (
<li key={order.orderNumber}>#{order.orderNumber}</li>
))}
</ul>
</div>
);
}Portal: Warehouse Operations (VMI)
// Stock that needs replenishing in a VMI warehouse
const replenish = await api.vmi.warehouse.replenish.list(warehouseUid, {});
// Receive stock into it
await api.vmi.warehouse.receive.create(warehouseUid, receipt);
// Its current availability
const availability = await api.vmi.warehouse.availability.list(warehouseUid, {});The VMI service also covers distributors, products, sections, inventory profiles and restocks; augur_discover(service="vmi") on the MCP server or the service's llms.txt lists every endpoint.
Best Practices
- Make API calls in server components or server actions, not in the browser.
- Never expose the JWT to the client: keep it in environment variables.
- See API Overview for edge caching, pagination and error handling.