signal.

Any Custom Frontend with Gradio's Backend

Hugging Face introduced gradio.Server, a FastAPI‑based framework that lets developers pair any custom frontend—such as React, Svelte, or plain HTML/JS—with Gradio’s backend services. The server adds Gradio’s queuing, concurrency control, SSE streaming, and ZeroGPU support on top of FastAPI’s routing and middleware capabilities. A demo application demonstrates a photo background‑removal tool with a complex web UI that communicates with the backend via the Gradio JS client, enabling queue management and GPU allocation without infrastructure headaches.

A few weeks ago, we wrote about one-shotting full web apps with gr.HTML : building rich, interactive frontends entirely inside Gradio using custom HTML, CSS, and JavaScript. That unlocked a lot. But what if that's not enough?

What if you want to build with your own frontend framework entirely like React, Svelte, or even plain HTML/JS, while still benefiting from Gradio's queuing system, API infrastructure, MCP support, and ZeroGPU on Spaces?

That's exactly the problem gradio.Server solves. And it changes what's possible with Gradio and Hugging Face Spaces.

Text Behind Image : an editor where you upload a photo, the background gets removed using an ML model, and then you place stylized text between the foreground subject and the background. The text appears to sit behind the person or object in the image.

There's no way to express this UI in Gradio components. It's a full web application. But We still wanted the backend power of Gradio: queuing, concurrency management, ZeroGPU support, and hosting on HF Spaces without infrastructure headaches.

gradio.Server extends FastAPI. It gives you the full power of FastAPI (custom routes, middleware, file uploads, any response type) while adding Gradio's API engine on top: queuing, SSE streaming, concurrency control, and gradio_client compatibility.

That's it. ~50 lines of Python. The model loads at startup, @spaces.GPU handles ZeroGPU allocation, and gradio.Server manages queuing and concurrency. Let's break down what's happening.

If this were a regular FastAPI app, you'd define a @app.post() route for background removal. That works, until two users hit it at once. Without concurrency management, both requests fight for the GPU, and the app crashes or returns garbage.

@app.api() solves this. It wraps your function with Gradio's queuing engine: requests are serialized, concurrency is controlled, and on ZeroGPU Spaces, GPU allocation is handled automatically via @spaces.GPU . As a bonus, any @app.api() endpoint is also callable via gradio_client , so other apps or scripts can use your Space programmatically:

Meanwhile, @app.get("/") is a standard FastAPI route that serves the HTML page. Both coexist naturally because Server is a FastAPI app.

The index.html in this example is a self-contained ~1300-line web application. No React, no build step, no bundler. Just vanilla HTML with:

The frontend talks to the backend using the Gradio JS Client :

This is the key part: by using the Gradio JS client rather than a raw fetch() call, the frontend goes through Gradio's queue. That means concurrency is managed, GPU requests don't collide, and you could even show queue position or progress to the user. Everything else, text rendering, layer compositing, export, happens in the browser.

With gradio.Server , Gradio doubles as a backend framework, use its UI system when you want it, bring your own frontend when you don't.

If you want Gradio's UI, you can use gr.Blocks , gr.Interface , gr.ChatInterface . If you want your own UI, use gradio.Server and bring whatever frontend you like. Either way, you get Spaces hosting, API queuing, gradio_client access, the full HF ecosystem, and more.

Upload any photo with a clear subject, and start layering text behind it. Try the 3D extrusion, perspective tilt, and stroke effects, they combine nicely.

This post covered the core idea: gradio.Server lets you pair any frontend with Gradio's backend. There's more to explore, including MCP tool registration with @app.mcp.tool() , SSE streaming for real-time updates, batch processing , and patterns for building multi-page apps with shared state.

Why it matters

Any Custom Frontend with Gradio's Backend. Covered by Hugging Face on April 1, 2026.

Topic dossiers Hugging Face