"use client";
import { createFalClient } from "@fal-ai/client";
import { useMemo, useState } from "react";
const fal = createFalClient({
// credentials: 'FAL_KEY_ID:FAL_KEY_SECRET',
proxyUrl: "/api/fal/proxy", // the built-int nextjs proxy
// proxyUrl: 'http://localhost:3333/api/fal/proxy', // or your own external proxy
});
type Image = {
url: string;
file_name: string;
file_size: number;
};
type Output = {
image: Image;
};
// @snippet:end
type ErrorProps = {
error: any;
};
function Error(props: ErrorProps) {
if (!props.error) {
return null;
}
return (
Error {props.error.message}
);
}
const DEFAULT_PROMPT =
"(masterpiece:1.4), (best quality), (detailed), Medieval village scene with busy streets and castle in the distance";
export default function Home() {
// @snippet:start("client.ui.state")
// Input state
const [prompt, setPrompt] = useState(DEFAULT_PROMPT);
const [imageFile, setImageFile] = useState(null);
// Result state
const [loading, setLoading] = useState(false);
const [error, setError] = useState(null);
const [result, setResult] = useState