Amazon Opensearch Serverless
Build at the speed of an idea with AWS. Create AWS resources like a new database or a search backend in seconds and add features on-demand as your application grows. Focus on coding, not infrastructure management - our serverless, fully managed services automatically scale with your workload and scale to zero when idle, so you only pay for what you use. Whether you're prototyping your next big idea or powering production AI and data-driven applications, AWS deliver the security, reliability, and price performance you need without the operational overhead.
Get started for free with $100 in credits towards any of these databases.
Start by connecting to your existing project and then run vercel link in the CLI to link to the project locally.
Connecting your project links the relevant environment variables. To use these variables in your local development environment, run:
vercel env pullInstall the OpenSearch SDK and the Vercel AWS helper that wires up SigV4 + OIDC:
npm install @opensearch-project/opensearch @vercel/awsCreate the OpenSearch client:
// lib/opensearch.tsimport { createOpenSearch } from '@vercel/aws';
const client = createOpenSearch();
export default client;You can create an index programmatically or via the OpenSearch Dashboards console:
// scripts/create-index.tsimport client from "@/lib/opensearch";
async function createIndex() { await client.indices.create({ index: "comments", body: { mappings: { properties: { comment: { type: "text" }, created_at: { type: "date" }, }, }, }, });}
createIndex();Update the page.tsx file to search and display comments from OpenSearch Serverless:
// app/page.tsximport client from "@/lib/opensearch";
export default async function Page() { const response = await client.search({ index: "comments", body: { query: { match_all: {}, }, sort: [{ created_at: { order: "desc" } }], }, });
const comments = response.body.hits.hits;
return ( <main className="main"> <h1 className="title">Next.js + OpenSearch Serverless</h1> <div className="container"> {comments.map((hit: any) => ( <div key={hit._id}> <p>{hit._source.comment}</p> <div className="metadata">{hit._id}</div> </div> ))} </div> </main> );}You're now ready to start your app locally:
npm run devNavigate to https://localhost:3000
Once ready, you can deploy your application to Vercel.
Select your preferred product and proceed to install. New to AWS? Create a new AWS account with $100 in credit - no credit card required (under free plan). Your credits remain available even after upgrading to a paid account later.
Under the free plan, new AWS customers get $100 in free credits to explore all eligible AWS services—valid for 6 months, no strings attached. As your needs grow, simply upgrade to a paid plan and scale beyond free tier limits. All billing is handled directly through AWS.