Disclaimer: This is definitely not one-sized-fits-all advice. Adjust to your own circumstances accordingly.
Ugh, I got laid off. Yes, and I saw it coming a mile away. The fact is, you will probably be laid off several times during your career and so you should be prepared for when it happens and learn to detect when it's coming.
Being laid off the first time can be a bit of a shock. Suddenly that place you went to every day is no longer in your life. You wake up with nowhere to go and the uncertainty of where you're going next. Not only is an end, it can also be the beginning of the next phase of your career.
After awhile you'll develop a sort of sixth sense when things are going bad for the company. You might notice employees jumping ship from other departments, or suddenly your manager can't look you in the eye. Suddenly the twelve bullet points you had at your weekly planning meeting have been stuck at one bullet point for awhile with no new work being assigned. There are a lot of things that can tell you the end is nigh.
If there was a prior round of layoffs and you survived, that's really a good time to start looking. Pay attention to whether the company is changing course in order to try to save itself. If not, you might want to start looking or at least being prepared. Not to be cliche, but doing the same thing expecting a different result is the definition of insanity.
If you know there's a good chance you'll be laid off, update your resume and start saving money immediately. Put extra money in savings and try to get at least two months ahead for expenses. If you're okay with jumping ship, then start looking for another job while you're still at your current job.
No matter which strategy you take, see what skills are currently in demand. Use the time you have to plug any knowledge holes and get some examples out on GitHub. For example, when I felt that my job was in jeopardy, I hopped on the Angular bandwagon. Everyone in Atlanta seems to be wanting to convert their existing .NET Websites over to Angular. Udemy is a great resource for learning, and it's cheap.
After you've been laid off, the first thing to do is tell your recruiters you are looking for a new job. If you already have a relationship with a recruiter(s), then notify them immediately and send them an updated version of your resume. do not turn on the "IM LOOKING FOR A JOB!" beacon at LinkedIn unless you really need a new recruiter. You'll be overwhelmed with phone calls and emails. They will insist on sending your resume to places that are two hours away with no work from home. It's also better to use a recruiter you've used in the past since you have good history with them and they can vouch for you. They probably already know what not to send you.
If you live in the US, sign up for your unemployment insurance during the first week as soon as possible. Even if you're getting severance. Having that bit of extra money coming in on top of your severance can be a nice bonus. If you are forced to visit your Department of Labor (DOL), stop and treat yourself to something nice like a Coffee at Starbucks or a burger somewhere, then take the rest of the afternoon off.
By the end of the week, you'll hopefully have scheduled some interviews or had a tech screening or two. You might even find something that sounds like your "Unicorn Job" that comes with a raise. That possibility along with a couple of backups, can make you feel a bit more motivated and can help you relax during the weekend. You're doing something, you're getting results and now you just need to make things happen.
While not at interviews or talking with your recruiters, practice your skills and take on-line courses. Work on an open project and keep yourself engaged in your skillset. Rest during the evenings. Make sure you follow the same routine you would while you were working. Don't stay up late and sleep in. If you like to work out, keep up your exercise regimen. Eat lunch when you would normally eat lunch. Take breaks from studying/looking for jobs when you need to.
During each week, unless you have an interview, try to take Fridays off and give yourself a three day weekend. Reward yourself for trying to find work.
The best part is when you get that offer. Now you can relax. Even better is when when your first day is a day or week away and you get a bit of vacation time before reentering the workforce.
When you're like me and been in this biz forover 21 years, being laid off is sort of just part of the developers career. Companies come and go, as well as positions. So make sure you're prepared for when if and when it happens.
By the way, as of the time of this publishing, I am currently waiting for an offer my recruiter a company is going to make me by the end of this week.