Hi,
Both are OK grammatically. Let's look into the speaker's mind at the long form of what is being said.
A: The car driver didn't hit you because he braked very quickly.
B:
Lucky for you.
Long version: It was lucky for you that he braked quickly. Adjectival form
A: The car driver didn't hit you because he braked very quickly.
B:
Luckily for you.
Long version: He braked very quickly, luckily for you. Adverbial form
In my opinion, 'luckily for you' is more stylistically accepted. It serves as a phrase that person B simply adds to the end of what person A has just said.
Best wishes, Clive