The Bible indicates that God revealed His will to selected people through dreams or visions in Scriptures such as Genesis 37:5-10; 1 Kings 3:5-15; Daniel, chapters 2 and 7; Matthew 1:20; 2:13,19; and Acts 10:9-16; 16:9.
God may communicate through dreams or visions even today, but we need to carefully check any such guidance we receive with Scripture and godly counsel to be sure it is from the Lord. Anything which contradicts Scripture is not from God. Our minds and even Satan are capable of producing great deception in such subjective areas.
2 Timothy 3:16-17 shows that God has revealed His will to us primarily through His Word. It says, “All Scripture is God-breathed and is useful for teaching, rebuking, correcting and training in righteousness, so that the man of God may be thoroughly equipped for every good work.”