Where can I file for child custody? (Which state has jurisdiction?)
Under a law called the Uniform Child Custody Jurisdiction and Enforcement Act (UCCJEA), you can only file for custody in the "home state" of the child unless you meet one of the exceptions, explained here: Are there any exceptions to the home state rule? The child's "home state" is the state where your child has lived with a parent or a person acting as a parent for the past six consecutive months. If your child is less than 6 months old, then your child's home state is the state where s/he has lived since birth. (Leaving the state for a short period of time does not change your child's home state.)
If you and your child recently moved to a new state, generally you cannot file for custody in that new state until you have lived there for at least six months. Until then, you or the other parent can start a custody action in the state where your child has most recently lived for at least 6 months. (There are some exceptions explained in the next question.)
Here are some examples:
My children lived in Texas their whole lives. We just moved to Oklahoma a few weeks ago (less than six months ago). In my case, Texas is my children's "home state." If I want to file for custody right now, I will probably need to file in Texas.
My children lived in Texas until we moved to Oklahoma 6 months ago. Because the children have lived in Oklahoma for 6 months, Oklahoma is their "home state." I will likely need to file for custody in Oklahoma (assuming there was no prior case in TX). However the other parent can ask Oklahoma to defer to Texas because Texas has more information about my children's lives that does Oklahoma. It would be up to the judge in Oklahoma.
My children lived in Oklahoma until they left to live with their father in Texas 2 months ago. Because they haven't lived in Texas for 6 months yet, their home state is still Oklahoma. If I want to file for custody, I can file in Oklahoma providing I haven't moved out of Oklahoma.