Skip to content
VercelLogotypeVercelLogotype
LoginSign Up

Next.js with Amazon OpenSearch

A Next.js app showcasing Amazon OpenSearch Serverless

DeployView Demo

Amazon OpenSearch Serverless Demo

This demo uses Amazon OpenSearch Serverless with Next.js to showcase full-text recipe search with facets, highlighting, and autocomplete. It connects securely using AWS SigV4 authentication, with credentials obtained via Vercel OIDC — no static AWS keys required.

How auth works

The app uses @vercel/oidc to read Vercel's short-lived OIDC token and exchanges it for AWS credentials via STS AssumeRoleWithWebIdentity (fromWebToken in the AWS SDK). On Vercel, VERCEL_OIDC_TOKEN is injected automatically; locally, vercel env pull writes one valid for ~12 hours.

Requirements

  • An Amazon OpenSearch Serverless Search collection
  • An IAM role whose trust policy allows Vercel's OIDC issuer (https://oidc.vercel.com/<team-slug>) and whose policy grants aoss:APIAccessAll on the collection. The Vercel AWS OpenSearch integration creates this role automatically and exposes it as the env vars below.
  • Node.js 18+

Environment variables

Provisioned automatically when you install the Vercel AWS OpenSearch integration. After vercel env pull .env.local you should see:

VariablePurpose
OPENSEARCH_ENDPOINTSearch collection endpoint
AWS_REGIONRegion of the search collection
AWS_ROLE_ARNIAM role with access to the search collection
VERCEL_OIDC_TOKENShort-lived Vercel OIDC token (auto-injected on Vercel; written locally by vercel env pull)

Configure the IAM role trust policy

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": { "Federated": "arn:aws:iam::<account-id>:oidc-provider/oidc.vercel.com/<team-slug>" },
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"oidc.vercel.com/<team-slug>:aud": "https://vercel.com/<team-slug>"
}
}
}
]
}

Local Setup

  1. Install dependencies:
npm install
  1. Link the project and pull env vars (this provisions VERCEL_OIDC_TOKEN):
vercel link
vercel env pull .env.local
  1. Seed the recipe index:
npm run seed
  1. Start the development server:
npm run dev
  1. View local development: http://localhost:3000

The local OIDC token expires after ~12 hours. If you see AWS auth errors mid-session, re-run vercel env pull .env.local --yes.

Learn More

  • Vercel OIDC Federation
  • @vercel/oidc on npm
  • Amazon OpenSearch Serverless
  • OpenSearch Query DSL
  • Next.js Documentation
GitHub Repovercel/aws-opensearch-demo
Use Cases
Starter
AI
Stack
Next.js
Tailwind

Related Templates

Next.js Boilerplate

Get started with Next.js and React in seconds.
Next.js Boilerplate thumbnail

Image Gallery Starter

An image gallery built on Next.js and Vercel Blob.
Image Gallery Starter thumbnail

Chatbot

A full-featured, hackable Next.js AI chatbot built by Vercel
Chatbot thumbnail

Get Started

  • Templates
  • Supported frameworks
  • Marketplace
  • Domains

Build

  • Next.js on Vercel
  • Turborepo
  • v0

Scale

  • Content delivery network
  • Fluid compute
  • CI/CD
  • Observability
  • AI GatewayNew
  • Vercel AgentNew

Secure

  • Platform security
  • Web Application Firewall
  • Bot management
  • BotID
  • SandboxNew

Resources

  • Pricing
  • Customers
  • Enterprise
  • Articles
  • Startups
  • Solution partners

Learn

  • Docs
  • Blog
  • Changelog
  • Knowledge Base
  • Academy
  • Community

Frameworks

  • Next.js
  • Nuxt
  • Svelte
  • Nitro
  • Turbo

SDKs

  • AI SDK
  • Workflow SDKNew
  • Flags SDK
  • Chat SDK
  • Streamdown AINew

Use Cases

  • Composable commerce
  • Multi-tenant platforms
  • Web apps
  • Marketing sites
  • Platform engineers
  • Design engineers

Company

  • About
  • Careers
  • Help
  • Press
  • Legal
  • Privacy Policy

Community

  • Open source program
  • Events
  • Shipped on Vercel
  • GitHub
  • LinkedIn
  • X
  • YouTube

Loading status…

Select a display theme:
    • AI Cloud
      • AI Gateway

        One endpoint, all your models

      • Sandbox

        Isolated, safe code execution

      • Vercel Agent

        An agent that knows your stack

      • AI SDK

        The AI Toolkit for TypeScript

      • v0

        Build applications with AI

    • Core Platform
      • CI/CD

        Helping teams ship 6× faster

      • Content Delivery

        Fast, scalable, and reliable

      • Fluid Compute

        Servers, in serverless form

      • Workflow

        Long-running workflows at scale

      • Observability

        Trace every step

    • Security
      • Bot Management

        Scalable bot protection

      • BotID

        Invisible CAPTCHA

      • Platform Security

        DDoS Protection, Firewall

      • Web Application Firewall

        Granular, custom protection

    • Company
      • Customers

        Trusted by the best teams

      • Blog

        The latest posts and changes

      • Changelog

        See what shipped

      • Press

        Read the latest news

      • Events

        Join us at an event

    • Learn
      • Docs

        Vercel documentation

      • Academy

        Linear courses to level up

      • Knowledge Base

        Find help quickly

      • Community

        Join the conversation

    • Open Source
      • Next.js

        The native Next.js platform

      • Nuxt

        The progressive web framework

      • Svelte

        The web’s efficient UI framework

      • Turborepo

        Speed with Enterprise scale

    • Use Cases
      • AI Apps

        Deploy at the speed of AI

      • Composable Commerce

        Power storefronts that convert

      • Marketing Sites

        Launch campaigns fast

      • Multi-tenant Platforms

        Scale apps with one codebase

      • Web Apps

        Ship features, not infrastructure

    • Tools
      • Marketplace

        Extend and automate workflows

      • Templates

        Jumpstart app development

      • Partner Finder

        Get help from solution partners

    • Users
      • Platform Engineers

        Automate away repetition

      • Design Engineers

        Deploy for every idea

  • Enterprise
  • Pricing
Log InContact
Sign Up
Sign Up
ContactDashboard
DeployView Demo
AI Gateway

One endpoint, all your models

Sandbox

Isolated, safe code execution

Vercel Agent

An agent that knows your stack

AI SDK

The AI Toolkit for TypeScript

v0

Build applications with AI

CI/CD

Helping teams ship 6× faster

Content Delivery

Fast, scalable, and reliable

Fluid Compute

Servers, in serverless form

Workflow

Long-running workflows at scale

Observability

Trace every step

Bot Management

Scalable bot protection

BotID

Invisible CAPTCHA

Platform Security

DDoS Protection, Firewall

Web Application Firewall

Granular, custom protection

Customers

Trusted by the best teams

Blog

The latest posts and changes

Changelog

See what shipped

Press

Read the latest news

Events

Join us at an event

Docs

Vercel documentation

Academy

Linear courses to level up

Knowledge Base

Find help quickly

Community

Join the conversation

Next.js

The native Next.js platform

Nuxt

The progressive web framework

Svelte

The web’s efficient UI framework

Turborepo

Speed with Enterprise scale

AI Apps

Deploy at the speed of AI

Composable Commerce

Power storefronts that convert

Marketing Sites

Launch campaigns fast

Multi-tenant Platforms

Scale apps with one codebase

Web Apps

Ship features, not infrastructure

Marketplace

Extend and automate workflows

Templates

Jumpstart app development

Partner Finder

Get help from solution partners

Platform Engineers

Automate away repetition

Design Engineers

Deploy for every idea