Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

Local drop-in replacement services for CI and no-network sandboxes. Fully stateful, production-fidelity API emulation. Not mocks.

Try every emulator in your browser at [emulate.dev/playground](https://emulate.dev/playground), with nothing to install.

## Quick Start

```bash
Expand Down
40 changes: 40 additions & 0 deletions apps/web/app/playground/[name]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { Metadata } from "next";
import { notFound } from "next/navigation";
import { EmulatorConsole } from "@/components/playground/emulator-console";
import { consoleServices } from "@/lib/playground/services";

type Props = { params: Promise<{ name: string }> };

function findService(name: string) {
const service = consoleServices.find((item) => item.name === name);
if (!service) notFound();
return service;
}

export function generateStaticParams() {
return consoleServices.map((service) => ({ name: service.name }));
}

export async function generateMetadata({ params }: Props): Promise<Metadata> {
const service = findService((await params).name);
return { title: `${service.label} playground`, description: service.description };
}

export default async function EmulatorPlaygroundPage({ params }: Props) {
const service = findService((await params).name);
return (
<div className="mx-auto flex w-full max-w-6xl flex-col gap-10 px-6 py-12 sm:py-16">
<header className="flex flex-col gap-2">
<h1 className="text-2xl font-semibold tracking-tight text-neutral-900 dark:text-neutral-50">{service.label}</h1>
<p className="text-sm text-neutral-600 dark:text-neutral-400">{service.description}</p>
<p className="text-sm text-neutral-500 dark:text-neutral-400">Runs in this tab. Nothing is sent to a server.</p>
</header>
<EmulatorConsole
key={service.name}
name={service.name}
groups={service.groups}
variables={service.variables ?? []}
/>
</div>
);
}
37 changes: 37 additions & 0 deletions apps/web/app/playground/flows/checkout/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import { CheckoutFlow } from "@/components/playground/flows/checkout";
import { flows } from "@/lib/playground/flows";

const flow = flows.find((candidate) => candidate.slug === "checkout");

export const metadata: Metadata = {
title: "Stripe checkout",
description: flow?.description,
};

export default function CheckoutFlowPage() {
if (!flow) notFound();

return (
<div className="mx-auto flex w-full max-w-4xl flex-col gap-8 px-6 py-12 sm:py-16">
<header className="flex flex-col gap-3">
<h1 className="text-3xl font-bold tracking-tight text-neutral-900 sm:text-4xl dark:text-neutral-50">
{flow.label}
</h1>
<p className="max-w-2xl text-base text-neutral-600 dark:text-neutral-400">{flow.description}</p>
<p className="text-sm text-neutral-500 dark:text-neutral-400">
Runs in this tab. Nothing is sent to a server.{" "}
<Link
href="/playground/stripe"
className="underline underline-offset-4 hover:text-neutral-900 dark:hover:text-neutral-100"
>
Open the Stripe console
</Link>
</p>
</header>
<CheckoutFlow />
</div>
);
}
35 changes: 35 additions & 0 deletions apps/web/app/playground/flows/file-sharing/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import { FileSharing } from "@/components/playground/flows/file-sharing";
import { mutedClass } from "@/components/playground/ui";
import { flows } from "@/lib/playground/flows";

const flow = flows.find((item) => item.slug === "file-sharing");

export const metadata: Metadata = {
title: "Vercel Blob sharing",
description: flow?.description,
};

export default function FileSharingPage() {
if (!flow) notFound();
return (
<div className="mx-auto flex w-full max-w-3xl flex-col gap-8 px-6 py-12 sm:py-16">
<header className="flex flex-col gap-2">
<h1 className="text-2xl font-semibold tracking-tight text-neutral-900 dark:text-neutral-50">{flow.label}</h1>
<p className="text-sm text-neutral-600 dark:text-neutral-400">{flow.description}</p>
<p className={mutedClass}>
Runs in this tab. Nothing is sent to a server.{" "}
<Link
href="/playground/vercel"
className="underline underline-offset-2 hover:text-neutral-900 dark:hover:text-neutral-100"
>
Open the Vercel console
</Link>
</p>
</header>
<FileSharing />
</div>
);
}
35 changes: 35 additions & 0 deletions apps/web/app/playground/flows/magic-link/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import { MagicLinkFlow } from "@/components/playground/flows/magic-link";
import { flows } from "@/lib/playground/flows";

const flow = flows.find((item) => item.slug === "magic-link");

export const metadata: Metadata = {
title: "Resend magic link",
description: flow?.description,
};

export default function MagicLinkPage() {
if (!flow) notFound();

return (
<div className="mx-auto flex w-full max-w-3xl flex-col gap-8 px-6 py-12 sm:py-16">
<header className="flex flex-col gap-2">
<h1 className="text-2xl font-semibold tracking-tight text-neutral-900 dark:text-neutral-50">{flow.label}</h1>
<p className="text-sm text-neutral-600 dark:text-neutral-400">{flow.description}</p>
<p className="text-sm text-neutral-500 dark:text-neutral-400">
Runs in this tab. Nothing is sent to a server.{" "}
<Link
href="/playground/resend"
className="underline underline-offset-2 hover:text-neutral-900 dark:hover:text-neutral-100"
>
Open the Resend console
</Link>
</p>
</header>
<MagicLinkFlow />
</div>
);
}
29 changes: 29 additions & 0 deletions apps/web/app/playground/flows/oauth-sign-in/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { Metadata } from "next";
import { notFound } from "next/navigation";
import { OAuthSignIn } from "@/components/playground/flows/oauth-sign-in";
import { mutedClass } from "@/components/playground/ui";
import { flows } from "@/lib/playground/flows";

const flow = flows.find((item) => item.slug === "oauth-sign-in");

export const metadata: Metadata = {
title: "OAuth sign-in",
description: flow?.description,
};

export default function OAuthSignInPage() {
if (!flow) notFound();

return (
<div className="mx-auto flex w-full max-w-3xl flex-col gap-8 px-6 py-12 sm:py-16">
<header className="flex flex-col gap-3">
<h1 className="text-3xl font-bold tracking-tight text-neutral-900 sm:text-4xl dark:text-neutral-50">
{flow.label}
</h1>
<p className="max-w-2xl text-base text-neutral-600 dark:text-neutral-400">{flow.description}</p>
<p className={mutedClass}>Runs in this tab. Nothing is sent to a server.</p>
</header>
<OAuthSignIn />
</div>
);
}
38 changes: 38 additions & 0 deletions apps/web/app/playground/flows/sms-verification/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import { SmsVerificationFlow } from "@/components/playground/flows/sms-verification";
import { mutedClass } from "@/components/playground/ui";
import { flows } from "@/lib/playground/flows";

const flow = flows.find((item) => item.slug === "sms-verification");

export const metadata: Metadata = {
title: "Twilio SMS verification",
description: flow?.description,
};

export default function SmsVerificationPage() {
if (!flow) notFound();

return (
<div className="mx-auto flex w-full max-w-3xl flex-col gap-8 px-6 py-12 sm:py-16">
<header className="flex flex-col gap-3">
<h1 className="text-3xl font-bold tracking-tight text-neutral-900 sm:text-4xl dark:text-neutral-50">
{flow.label}
</h1>
<p className="max-w-2xl text-base text-neutral-600 dark:text-neutral-400">{flow.description}</p>
<p className={mutedClass}>
Runs in this tab. Nothing is sent to a server.{" "}
<Link
href="/playground/twilio"
className="font-medium text-neutral-900 underline underline-offset-4 dark:text-neutral-100"
>
Open the Twilio console
</Link>
</p>
</header>
<SmsVerificationFlow />
</div>
);
}
24 changes: 24 additions & 0 deletions apps/web/app/playground/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { ReactNode } from "react";
import { PlaygroundSidebar, type SidebarGroup } from "@/components/playground/sidebar";
import { flows } from "@/lib/playground/flows";
import { consoleServices } from "@/lib/playground/services";

const groups: SidebarGroup[] = [
{
title: "Flows",
links: flows.map(({ slug, label }) => ({ href: `/playground/flows/${slug}`, label })),
},
{
title: "API consoles",
links: consoleServices.map(({ name, label }) => ({ href: `/playground/${name}`, label })),
},
];

export default function PlaygroundLayout({ children }: { children: ReactNode }) {
return (
<div className="flex flex-col md:flex-row">
<PlaygroundSidebar groups={groups} />
<div className="min-w-0 flex-1">{children}</div>
</div>
);
}
70 changes: 70 additions & 0 deletions apps/web/app/playground/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import type { Metadata } from "next";
import Link from "next/link";
import { flows } from "@/lib/playground/flows";
import { consoleServices } from "@/lib/playground/services";

export const metadata: Metadata = {
title: "Playground",
description: "Try each emulator in your browser tab. Nothing is sent to a server, and a reload starts fresh.",
};

const sections = [
{
title: "Flows",
intro: "Guided demos that drive an emulator through a real app feature.",
items: flows.map((flow) => ({
href: `/playground/flows/${flow.slug}`,
label: flow.label,
description: flow.description,
meta: flow.services.join(", "),
})),
},
{
title: "API consoles",
intro: "Every operation an emulator supports, ready to send with its method, path, headers, and body filled in.",
items: consoleServices.map((service) => ({
href: `/playground/${service.name}`,
label: service.label,
description: service.description,
meta: `${service.groups.reduce((total, group) => total + group.presets.length, 0)} requests`,
})),
},
];

export default function PlaygroundPage() {
return (
<div className="mx-auto flex max-w-5xl flex-col gap-12 px-6 py-16 sm:py-20">
<header>
<h1 className="mb-4 text-3xl font-bold tracking-tight text-neutral-900 sm:text-4xl dark:text-neutral-50">
Playground
</h1>
<p className="max-w-2xl text-base text-neutral-600 dark:text-neutral-400">
Each emulator runs inside your browser tab. Nothing is sent to a server, and every visitor gets a private
copy. Reload the page to start fresh.
</p>
</header>
{sections.map((section) => (
<section key={section.title} className="flex flex-col gap-4">
<div className="flex flex-col gap-1">
<h2 className="text-lg font-semibold text-neutral-900 dark:text-neutral-100">{section.title}</h2>
<p className="text-sm text-neutral-600 dark:text-neutral-400">{section.intro}</p>
</div>
<ul className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
{section.items.map((item) => (
<li key={item.href}>
<Link
href={item.href}
className="flex h-full flex-col gap-2 rounded-lg border border-neutral-200 p-4 hover:border-neutral-300 dark:border-neutral-800 dark:hover:border-neutral-700"
>
<span className="text-sm font-medium text-neutral-900 dark:text-neutral-100">{item.label}</span>
<span className="text-sm text-neutral-600 dark:text-neutral-400">{item.description}</span>
<span className="mt-auto text-xs text-neutral-500 dark:text-neutral-400">{item.meta}</span>
</Link>
</li>
))}
</ul>
</section>
))}
</div>
);
}
9 changes: 8 additions & 1 deletion apps/web/app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import type { MetadataRoute } from "next";
import { allDocsPages } from "@/lib/docs-navigation";
import { flows } from "@/lib/playground/flows";
import { consoleServices } from "@/lib/playground/services";
import { canonicalUrlFor } from "@/lib/site";

export default function sitemap(): MetadataRoute.Sitemap {
return ["/", ...allDocsPages.map((page) => page.href)].map((href) => ({ url: canonicalUrlFor(href) }));
const playground = [
"/playground",
...flows.map((flow) => `/playground/flows/${flow.slug}`),
...consoleServices.map((service) => `/playground/${service.name}`),
];
return ["/", ...allDocsPages.map((page) => page.href), ...playground].map((href) => ({ url: canonicalUrlFor(href) }));
}
Loading
Loading