import { createFalClient } from "@fal-ai/client";
import { useMemo, useState } from "react";
// @snippet:start(client.config)
const fal = createFalClient({
proxyUrl: "/api/fal/proxy", // the built-int nextjs proxy
// proxyUrl: 'http://localhost:3333/api/fal/proxy', // or your own external proxy
});
// @snippet:end
// @snippet:start(client.result.type)
type Image = {
url: string;
file_name: string;
file_size: number;
};
type Output = {
images: Image[];
};
// @snippet:end
type ErrorProps = {
error: any;
};
function Error(props: ErrorProps) {
if (!props.error) {
return null;
}
return (
Error {props.error.message}
);
}
const DEFAULT_PROMPT =
"a city landscape of a cyberpunk metropolis, raining, purple, pink and teal neon lights, highly detailed, uhd";
export function Index() {
// @snippet:start("client.ui.state")
// Input state
const [prompt, setPrompt] = useState(DEFAULT_PROMPT);
// Result state
const [loading, setLoading] = useState(false);
const [error, setError] = useState(null);
const [result, setResult] = useState