Can you build a SPA with a separate frontend and backend?

Hey everyone! I’m trying to understand how to build a Single Page Application (SPA) the right way. I’ve seen a lot of examples where the frontend and backend are mixed together, like using Twig in Symfony2 with AngularJS.

But I thought it was common to keep them separate and just connect them with an API. This way, if I want to switch PHP frameworks later, I can do it without messing up the frontend.

What’s the best way to do this? Are there any good examples out there? I’d love to see how others handle this separation. Maybe there’s a GitHub repo or tutorial that shows it in action?

I’m still learning, so any advice or resources would be super helpful. Thanks in advance!

yeah, totally! separating frontend and backend is super common for SPAs. i’ve done it with react + node.js before. it’s pretty sweet cuz you can swap out parts easier. just make sure ur API is solid. have u checked out any tutorials on youtube? there’s tons of good stuff there for beginners

Absolutely, you can build a SPA with separate frontend and backend components. This approach, often called a decoupled architecture, offers several advantages. It allows for greater flexibility, easier maintenance, and the ability to scale each part independently.

For the frontend, you might consider using a framework like React, Vue, or Angular. These can handle the client-side rendering and state management efficiently. On the backend, you could use any server-side technology that can expose RESTful APIs or GraphQL endpoints.

The key is to design a robust API that serves as the bridge between your frontend and backend. This API would handle data transfer, authentication, and other necessary interactions. By keeping these separate, you gain the freedom to evolve each part of your application independently, which can be invaluable as your project grows or requirements change.

ooh, interesting question! :thinking: have u considered using a framework like react or vue for the frontend? they work great with separate backends. i’m curious, what’s ur experience with apis so far? it’d be cool to hear more about ur project goals. maybe we can brainstorm some ideas togethe?