Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jjmaster's avatar

Best practice to render inertia answers for a component request from two different routes

Hello:

After coding with Inertia for a while (stack: VUE + Laravel) the moment has arrived when I have to use a component in two different pages in different routes.

So I have a component that retrieves information from /getConversationByID in the backend but that component is used in two different routes:

Main/Index.vue
Admin/index.vue

Which is the best practice to handle the return endPoint the Inertia::render has to use? This is how I return the answers right now:

Route::post('getConversationByID', function(Request $request){

        //Logic $result = ...

        return Inertia::render('Main',[
            'destinationProp' => $result
        ]);

    });

Thanks a lot. My best regards.

0 likes
1 reply
martinbean's avatar

@jjmaster Why are you POST-ing to get a conversation? If you’re getting things then you should use the GET method. And if you’re getting something by ID, then the convention is to just specify the ID as part of the URI:

GET /conversations/{id}

No need to POST. And no need to have weird getFooById URIs.

Please or to participate in this conversation.