Is this best practice for Dynamically adding items to WordPress menus?

It’s always hard to say which way to solve some problem is the best, because it’s based on opinions and believes. But…

There are 3 ways I would use (depending on context and needs) to add such menu item:

1. Using wp_get_nav_menu_items filter

Exactly the way you’re doing in your question. The only problem with it is that you have to be careful and fill all needed fields of the $item object. Otherwise it may cause warnings and notices.

PS. The wp_nav_menu_objects filter is pretty similar and it’s also used for this purpose very often.

2. Using wp_nav_menu_items filter to append some items

This filter gets a string containing HTML code for menu items. So it’s pretty easy to append some HTML code to given menu. The items you add this way won’t be visible/editable in wp-admin.

So it’s a pretty good idea to use it, if you want to add some special links to specific menu, that should always be at the beginning or at the end – let’s say Login/Logout link…

3. Using one of above filters to rewrite some menu items

It’s another pretty common practice. Let’s say you want to put a Login/Logout link and allow user to edit its label and position. But of course you don’t want force user to edit its URL.

In such way you can add some placeholder as URL and then use the filter to rewrite it. For example you can add “Sign in | Sign out” as label and “#loginouturl” as URL, and then use filters to change the label and url based on current user (if his logged in or anonymous).

Every one of these solutions has its good and bad sides. Some of them are better in some cases.