You can take your baby to the beach with you as soon as you bring the baby home from the hospital as long as you protect them more from the sun.
Babies under 6 months of age and especially newborns can wear sunscreen but some babies under 6 months of age may get a rash or irritation from the sunscreen.
Most times it's recommended to wait until the baby is at least 6 months of age before taking them to the beach when you can really apply some sunscreen to protect them.
But you can take the baby to the beach whenever you want too.
Babies under 6 months of age are not supposed to wear sunscreen because of the babies skin's fragility and permeability.
Due to the babies delicate, thin and fragile skin the sunscreen can cause irritation to the babies skin.
My babies pediatrician however said that I could try putting a small amount of sunscreen on my babies when they were under 6 months old.
I did and nothing bad happened but some babies may get irritation from it.
You can however also just keep the baby out of the direct sun and protect them that way or wait until the baby is at least 6 months or above to take the baby somewhere where you need sunscreen.
When taking the baby out in the stroller use a shade over them to protect the baby from the strong UV rays of the sun.