Limit post views for non-members?

Looking to limit post views for non-members… has anyone done something like this before? Similar to how certain news publications limit post views for non-members then direct you to their paywall

Checked for older topics but didn’t find anything in recent history.