The solution to this problem is to work the foundation chain and first row of stitches at the same time, using what are known as foundation stitches. This guarantees that you will have the exact right amount of chain stitches needed for the first row of stitches, and the finished product looks almost exactly the same as if the foundation row were crocheted separately from the first row of stitches. The best part is, foundation stitches may be used in any crochet pattern that does not skip chains in the first row and does not have more than one stitch being worked in any foundation chain.
While there are many tutorials online for how to specifically do a foundation single crochet, foundation double crochet, etc, we decided we'd rather explain the general concept of how a foundation stitch works, so that it may be applied to any stitch that is needed in the first row.
Next, yarn over the appropriate number of times needed to work the stitch as usual, and insert the hook in the last chain from the hook. This means for a single crochet, you would not yarn over before inserting the hook, because a normal single crochet does not require a yarn over. For a double crochet, you would yarn over once before inserting the hook. For a treble crochet, you would yarn over twice, and so on. But for all stitches, the hook is inserted into the chain furthest from the hook.
Pull a loop through the chain stitch.
Now, before completing the stitch, yarn over and pull a loop through just the first loop on the hook. This creates the foundation chain, as indicated by the arrow in the photo. This is the secret to working any foundation stitch. All you are doing is working a chain stitch before working the actual stitch. After creating this chain, you should have the appropriate number of loops left on the hook to complete the stitch as you normally would.
To start the next stitch, yarn over the appropriate number of times (zero for a foundation single crochet), and insert the hook into the foundation chain you made in the last step.
...then yarn over and pull a loop through just the first loop on the hook to make the next foundation chain.
And again, complete the stitch as usual. The next stitch will be worked in the new foundation chain you just made.
Continue working this way until the desired number of stitches worked. You will notice that this foundation row will grow vertically, with the chains on the left and the stitches on the right.
When you are ready to start the next row, simply turn the work so that the chains are on the bottom, work your turning chain, turn the work, and work your second row as usual.
This technique has gained popularity in recent years because of the convenience it provides in not having to count stitches in the beginning chain. It is best used in simple patterns, however. For patterns with complicated or lacy stitch patterns, please see our post, "The Foundation Chain: Three Ways to Begin."