For the above mentioned problem, To render conditionally I would highly suggest to use conditional parallel routes(Note: parallel routes don't work as expected for dynamic routes), But for a normal route it works like a charm and is part of the layout.
Also, if possible I would suggest you to use server component and rely on server functions for auth related checks and flows. This would possible help you in following ways
P.S: I understand that the passed child of client component can be a server component.
Second, if you have different route paths for authenticated and un-authenticated users, then as suggested by @lalit-fauzdar in his answer, use middleware to dynamically routes the users to the respective routes.
P.S: It would be helpful if you could share the error shown.