In the course of the Gemara’s discussion of Kiddush, one of the traditions mentioned is that some communities make Kiddush in the synagogue on the eve of Shabbat.
The Gemara asks: …why do I need to recite kiddush in the synagogue at all, if one does not fulfill his obligation with that kiddush? The Gemara answers: The purpose of kiddush in the synagogue is to fulfill the obligations of the guests who eat and drink and sleep in the synagogue. Since these visitors are staying in the synagogue for Shabbat, they must hear kiddush there.
The rishonim ask how guests could be housed and fed in the synagogue, when the holiness of batei Knesset (synagogues) should forbid such use. Several answers are suggested:
The Gemara is referring specifically to synagogues in Bavel (or other places outside of Israel) where the batei Knesset do not have a full level of kedusha.
Perhaps the guests were Torah scholars, who are permitted to make use of a synagogue for purposes other than prayer and study because the bet Knesset is considered to be like their home.
Some suggest that any poor person or traveler with no place to stay will be granted the status of a Torah scholar with regard to their rules.
Finally, it is possible that certain synagogues were originally built on the condition that they could be used for such purposes.
In many communities there is still a tradition to make Kiddush on Friday night in the synagogue, even if there are no guests. Whether this is appropriate was a question presented to the Ge’onim. Rav Hai Ga’on ruled that if there are no guests, Kiddush should not be recited. Other Ge’onim argue that Kiddush should be made in the synagogue in any case, either on behalf of those congregants who do not have wine at home, or because there is a spiritual, healing aspect of the synagogue Kiddush beyond the simple obligation to fulfill the mitzva of welcoming the Shabbat around the meal.
According to the ruling of the Shulhan Arukh (Orah Hayyim 269:1), if Kiddush is made in the synagogue, the cup should be given to one of the children to drink, since it would be inappropriate to drink the Kiddush wine without eating a meal. In Israel the tradition is that Kiddush is not recited in the bet Knesset.