All integrations·Framework examples

Next.js (App Router)

Active

Server Components + client AddressFinder, validation in a Server Action.

Install

Client widget
npm i @postio/react @tanstack/react-query
Server validation
npm i @postio/node

30-second example

// app/checkout/page.tsx
'use client';

import { PostioProvider, AddressFinder } from '@postio/react';

export default function CheckoutPage() {
  return (
    <PostioProvider apiKey={process.env.NEXT_PUBLIC_POSTIO_KEY!}>
      <AddressFinder
        onSelect={(addr) => console.log(addr)}
        placeholder="Start typing an address…"
      />
    </PostioProvider>
  );
}

// app/checkout/actions.ts
'use server';
import { Postio } from '@postio/node';

const postio = new Postio({ apiKey: process.env.POSTIO_API_KEY! });

export async function validatePostcode(postcode: string) {
  const { results } = await postio.address.postcode(postcode);
  return results;
}