AWHILE is an adverb, meaning “briefly” or “for a time.”
A WHILE is a noun phrase comprised of two words: “a” (the article) and “while” (the noun). The phrase means “a period of time.”
For example, “The kids played awhile in the backyard.”
For example “He ran for a while before he needed to take a water break.”
The noun phrase “a while” often follows a preposition, such as “for” (for a while) or “in” (in a while). Since prepositions need objects, you must use the noun phrase (a while) because adverbs cannot follow prepositions. Thus, “for awhile” and “in awhile” are not considered correct.
Getting these correct in a sentence is actually pretty easy when you use the substitution trick! Sub out the awhile/a while with a similar functioning word and see if the sentence still makes sense.
If you can replace “awhile” (adverb) with another adverb such as “briefly,” you know you want the one-word version. If you can replace “a while” (article + noun) with another article and noun such as “a month,” you know you want the two-word version. If your substitution doesn’t make sense, recheck your word function.
“The kids played awhile in the backyard.” = “The kids played briefly in the backyard” ✓
“He ran for a while before he needed to take a water break.” = “He ran for an hour before he needed to take a water break.”✓
One more memory trick:
Awhile = Adverb (both begin with A)
A while = noun phrase (“a while” is two words and “noun phrase” is two words)