DEV Community

Cover image for Serve the API and Flutter App Together
YeLinAung for dust

Posted on Originally published at dust-codegen.pages.dev

Serve the API and Flutter App Together

Dust tutorial showing a Dart server serving API routes and a Flutter web app together

Serve the API and Flutter app from one Dart server.

That is a simple full-stack setup.

The API owns the /api routes.

The Flutter app owns the browser routes, like /products/42.

dust_server can put both behind one router. API routes run first. Anything the API does not claim can fall back to the built Flutter web app.

This matters for path URLs.

If a user refreshes /products/42, the server should send index.html. Then Flutter Routing can read the URL and open the right screen.

The app logic stays split:

  • server routes handle API work;
  • Flutter routes handle screens;
  • the generated HTTP client calls /api;
  • the same server serves the built app.

This is not server-side rendering. It is one process serving an API and a client-side Flutter app.

Docs used: dust_server web apps, Dust Routing deep links, Dust HTTP clients, and Flutter URL strategies.

Dust #DustServer #Routing #HTTPClient #Flutter

Top comments (0)