Sorry you are going through this op. I remember it well.
I couldn't keep it a secret when I found out. He was at work at the time (with his OW), so while he was out, I packed him a bag, took the dc to my parents house and when he got home and walked through the door, I told him I knew and that his bag was packed. I also told him that we would be telling the dc together the following day.
That next day was easily the worst of my life and I don't think there is any way to lessen the pain for children when their parents separate, but we sat them down together and told them that we loved them more than anything and that will never change, but we are not making each other happy anymore and will be separating.
Not a lie as such, as clearly I wasn't making him happy and his affair wasn't making me happy. At 10 and 11, they didn't need to know the ins and out of their dad's affair and rightly or wrongly, I wanted them to have a good relationship with him going forward.
I did say to him that if they ever ask me when they are older then I won't lie to them, but at now 15 and 17 they haven't asked and we have done everything we can to make things easier for them. I hated him to start with and could barely look at him but I dug really fucking deep and pretended we were friends, until, 6 years later I guess we are.
Despite his twattish behaviour, he has been reasonable with finances and I was able to buy him out of the family home. Guilt I guess but I don't care.
Anyway, these first few weeks and months are crap. They just are. But it will get easier, I promise. Lean on your friends and family and get yourself some counselling if you can to help you process things with an impartial party. Those things really helped me. Find a good solicitor too.
Good luck op x