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
Ownervercel
Repositoryaws-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

Agent Stack

  • AI SDK
  • AI Gateway
  • Sandbox
  • Workflows
  • EveNew
  • ConnectNew

Core Platform

  • CI/CD
  • Content Delivery
  • Fluid Compute
  • Observability

Security

  • Platform Security
  • WAF
  • Bot Management
  • Bot ID

Tools

  • Vercel DropNew
  • Vercel Agent
  • Vercel PluginNew
  • Next.js
  • Domains
  • v0

Frameworks

  • Nuxt
  • SvelteKit
  • Nitro
  • Turborepo
  • Tanstack Start
  • FastAPI
  • xmcp
  • All frameworks

SDKs

  • Vercel SDK
  • Workflow SDKNew
  • Flags SDK
  • Chat SDKNew
  • Queues SDKNew
  • Streamdown

Build

  • AI Apps
  • Web Apps
  • Marketing Sites
  • Platforms
  • Commerce
  • Platform Engineers
  • Design Engineers

Learn

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

Explore

  • Customers
  • Marketplace
  • Templates
  • Partner Finder
  • Vercel + AWS

Company

  • About
  • Careers
  • Press
  • Events
  • Startups
  • Shipped on Vercel
  • Open Source Program
  • Enterprise
  • Pricing
  • Help

Legal & Trust

  • Privacy Policy
  • Terms of Service
  • Cookie Policy
  • DPA
  • Acceptable Use Policy
  • Legal (all documents)
  • Trust Center
  • Status

Social

  • GitHub
  • X
  • LinkedIn
  • YouTube
  • Instagram
  • VercelVercel
Agent Stack
  • AI SDK
  • AI Gateway
  • Sandbox
  • Workflows
  • Eve
Core Platform
  • Security
  • Content Delivery
  • Fluid Compute
  • Observability
  • CI/CD
Tools
  • Next.js
  • Vercel Agent
  • Vercel Plugin
  • Domains
  • v0
Learn
  • Docs
  • About
  • Blog
  • Changelog
  • Knowledge Base
Build
  • AI Apps
  • Web Apps
  • Marketing Sites
  • Platforms
  • Commerce
Explore
  • Customers
  • Marketplace
  • Partner Finder
  • AWS
  • Community
EnterprisePricing
Contact
Log InSign Up
Dashboard

Products

Agent Stack

  • AI SDK
  • AI Gateway
  • Sandbox
  • Workflows
  • Eve

Core Platform

  • Security
  • Content Delivery
  • Fluid Compute
  • Observability
  • CI/CD

Tools

  • Next.js
  • Vercel Agent
  • Vercel Plugin
  • Domains
  • v0
Resources

Learn

  • Docs
  • About
  • Blog
  • Changelog
  • Knowledge Base

Build

  • AI Apps
  • Web Apps
  • Marketing Sites
  • Platforms
  • Commerce

Explore

  • Customers
  • Marketplace
  • Partner Finder
  • AWS
  • Community
Enterprise
Pricing
Sign UpLog In
Contact
DeployView Demo

Loading status…

Select a display theme: