סימן קלט סעיף יח
בְּמוֹצָאֵי שַׁבָּת, מַבְדִּילִין וְאַחַר כָּךְ מַדְלִיקִין נֵר חֲנֻכָּה. וּבְבֵית הַכְּנֶסֶת, מַדְלִיקִין קֹדֶם וְיִתֶּן לְךָ.
On Shabbos night you should recite Havdalah27According to Ramah, the precedure is reversed—the Chanukah lights are kindled before the Havdalah is said. Everyone should adhere to the custom of the community. (Mishnah Berurah 681:3) and then kindle the Chanukah lights. In the synagogue the lights are kindled before Veyiten lecha is said.
תנא דבי אליהו כל השונה הלכות בכל יום מובטח לו שהוא בן העולם הבא שנאמר הליכות עולם לו אל תקרי הליכות אלא הלכות (נדה ע"ג.)