Skip to main content
This guide walks you through creating a Next.js application with Retab widgets from scratch. You’ll build a single-page demo that showcases all widgets in an interactive accordion.

Step 1: Create a New Next.js App

Create a new Next.js application using the App Router:
Install the required packages:

Step 2: Environment Variables

Create a .env.local file in your project root:
.env
Get your API key and project ID from the Retab dashboard.

Step 3: Create the Token Endpoint

app/api/retab/token/route.ts

Step 4: Create the Providers Component

Since the root layout is a Server Component and RetabProvider requires client-side features, create a separate client component for providers.
app/providers.tsx

Step 5: Configure the Root Layout

app/layout.tsx
The root layout remains a Server Component (no “use client”), which allows you to use metadata exports and other server-only features. The Providers component handles the client-side context.

Step 6: Create the Widgets Demo Page

app/page.tsx

Step 7: Run the Application

Start your development server:
Open http://localhost:3000 to see the widgets demo. You can:
  • Browse widgets by category in the sidebar accordion
  • Click on any widget to see it live
  • Interact with the widgets using your project’s data

Project Structure

Project Structure

Adding Authentication

In production, protect the token endpoint with your auth solution:
app/api/retab/token/route.ts

Next Steps

  • Add your preferred authentication
  • Customize the sidebar styling
  • Deploy to Vercel or your hosting platform