Should I ride my bike on the beach?
Sand + Saltwater and unsealed bearings are not a good mix.
Some things to consider depending on the value of your bike and cost for replacement parts are:

Upgrading your bottom bracket to a sealed bearing. Sure there is some frictional loss there but even road cyclist use it on training bikes for bad weather riding

Upgrade wheel bearings to sealed bearings/rebuild them more frequently

I assume your bike is either aluminum or carbon not steel. If it is steel washing it to prevent corrosion from salt would be a must and touching up paint chips to protect the steel is a must too.

Clean braking surfaces after each ride whether rim or disc brakes to avoid sand wearing them out prematurely.

Use a proper lube on the chain and clean your chain frequently. I personally would use a wet lube, but if you consistently find yourself in powder sand, then perhaps a dry lube would work and avoid having sand stick to it. However, I have found that dry lubes tend to lose their functionality even after 1 splash from a puddle so chose carefully there. Some suggested lubes that I have used (WD40 Wet Bike Lube and Finish Line Ceramic). I find 100 - 200 mile chain cleans work well for me on road conditions. If I rode on the beach and had a lot of sand stuck to the chain, I might service the chain more often like after each long ride, etc. Here is a link to a typical chain clean service -