How to add "web" to an api-only phoenix project?

I have a mature (2-3 years) Phoenix project which is in APi only mode. I wanted to add an endpoint to start rendering things directly besides the client/front apps which still work through the API.

What’s all i have to do?
It’s currently in phoenix 1.4, i think it started as 1.0.

I know you can do “mix test” and compare, but this is a large project that has been mutating up to 1.4 and i suppose it was created with mix, and that differs a lot from the current generator.

Well you’ll make a set of web routes, probably with their own pipeline, in the router. Then you’ll probably want to use eex templates (you might even be using some in json depending). Other than that it’s mostly the same. :slight_smile:

Just start with adding a web pipeline and such routes, then ‘render’ as normally in the controller and handle template errors by filling in things as they popup. Just ask here with any specific issues and we can help! :slight_smile:

1 Like

ok, but there’s a webpack and package.json, and i suppose something that generates assets, right?
I’m looking at LiveView docs

Only if you need them, I have another pipeline altogether that handles that so I don’t use those. It all depends on what you are wanting. You can pretty easily just generate a new scratch one and just piece out the parts you are wanting. Phoenix is extremely composable. :slight_smile:

1 Like