Kiddush at shul?

(א) יש מקומות שאין מקדשין בבה"כ מפני שאין שם אורחים ושאלתי אם הדין עמהם וטוב למנוע המקדשים או אם טוב לקדש ולהבדיל כמנהג רוב המקומות:

(ב) והשיבו אעפ"י שאין קידוש אלא במקום סעודה מצוה לקדש ולהבדיל בבה"כ משום ברוב עם הדרת מלך, ועוד נרות חנוכה מדליקין בבה"כ אע"פ שכל או"א מדליק בביתו, ועוד כי יש אנשים שאינם יודעים לקדש ולהבדיל וכששומעין בבה"כ נותנים אל לבם ולומדים ומקדשים בביתם:

(1) There are some places where Kiddush is not recited in the synagogue when there are no guests present. I asked [in a dream] whether they are correct, and whether it is better to prevent people reciting Kiddush in such a case, or whether it is better to recite Kiddush and Havdala in the synagogues, as is the prevalent custom.

(2) They responded: Even though Kiddush is only recited in the place where a meal is eaten (Pesachim 101a:3), it is nonetheless a commandment to recite Kiddush and Havdala in the synagogue. For "in the multitude is the glory of the King" (Proverbs 14:28). Moreover, Channukah candles are also lit in the synagogue, even though each person lights in their own home. So too, there are some people who don't know how to recite Kiddush and Havdalah, and when they hear it in the synagogue, they are encouraged and learn it, and later recite it at home.

Pesachim 100b in Vilna format - read with either Rashi or Rashbam, and the Tosafot beginning Yedei Kiddush Yatzu

אוֹתָם בְּנֵי אָדָם שֶׁקִּידְּשׁוּ בְּבֵית הַכְּנֶסֶת, אָמַר רַב: יְדֵי יַיִן לֹא יָצְאוּ, יְדֵי קִידּוּשׁ יָצְאוּ. וּשְׁמוּאֵל אָמַר: אַף יְדֵי קִידּוּשׁ לֹא יָצְאוּ. אֶלָּא לְרַב, לְמָה לֵיהּ לְקַדּוֹשֵׁי בְּבֵיתֵיהּ? כְּדֵי לְהוֹצִיא בָּנָיו וּבְנֵי בֵיתוֹ. וּשְׁמוּאֵל, לְמָה לִי לְקַדּוֹשֵׁי בְּבֵי כְנִישְׁתָּא? לְאַפּוֹקֵי אוֹרְחִים יְדֵי חוֹבָתָן, דְּאָכְלוּ וְשָׁתוּ וְגָנוּ בְּבֵי כְנִישְׁתָּא.

וְאַזְדָּא שְׁמוּאֵל לְטַעְמֵיהּ, דְּאָמַר שְׁמוּאֵל: אֵין קִידּוּשׁ אֶלָּא בִּמְקוֹם סְעוּדָה. סְבוּר מִינַּהּ: הָנֵי מִילֵּי מִבַּיִת לְבַיִת, אֲבָל מִמָּקוֹם לְמָקוֹם בְּחַד בֵּיתָא — לָא. אֲמַר לְהוּ רַב עָנָן בַּר תַּחְלִיפָא: זִימְנִין סַגִּיאִין הֲוָה קָאֵימְנָא קַמֵּיהּ דִּשְׁמוּאֵל, וְנָחֵית מֵאִיגָּרָא לְאַרְעָא וַהֲדַר מְקַדֵּשׁ.​​​​​​​

The Gemara continues to discuss the halakhot of kiddush: With regard to those people who recited kiddush in the synagogue, as was customarily done at the conclusion of the prayer service on Shabbat night, Rav said: They have not fulfilled their obligation to recite a blessing over wine. That is, the blessing over the wine in the synagogue does not enable them to drink wine at home without an additional blessing. However, they have fulfilled their obligation of reciting kiddush. And Shmuel said: Even the obligation of kiddush they have not fulfilled, and they must recite kiddush again at home. The Gemara asks: But according to the opinion of Rav, why should one have to recite kiddush a second time at home if he has already fulfilled his obligation in the synagogue? The Gemara answers: He must repeat kiddush to fulfill the obligations of his children and the members of his household, who did not come to the synagogue. The Gemara asks: But according to the opinion of Shmuel, 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. And Shmuel follows his line of reasoning, as Shmuel said: There is no valid kiddush except in the place of one’s Shabbat meal. If one does not eat a meal in the location in which he recites kiddush, he has not fulfilled the mitzva of kiddush. The students understood from this statement that this halakha applies only when one goes from house to house and eats the Shabbat meal in a different house from the one in which he recited kiddush. But if one went from the place where he recited kiddush to another place in one house, no, there is no problem, and he has fulfilled the mitzva of kiddush. However, Rav Anan bar Taḥalifa said to the students: Many times I stood before Shmuel, and he descended from the roof to the ground floor and recited kiddush again. This indicates that Shmuel maintains that even if one recites kiddush and eats the Shabbat meal in a different part of the same house, he must recite kiddush a second time.

ידי יין לא יצאו - שאם יש להם יין בביתם לשתות חייבין לברך בפה''ג שאינן פטורין בברכת הכוס של שתיית יין ששתו בבהכ''נ מאחר שעקרו ממקומן דה''ל היסח הדעת וצריך לברך אבל המקדש בביתו על שולחנו בשבת א''צ לברך על היין שבתוך הסעודה שהרי פוטרו יין שלפני הסעודה...

ידי קידוש יצאו - אף על פי שלא שתו רק שיטעום המברך או אפילו אחד מהם כדמוכח בסוף בכל מערבין (עירובין דף מ:). ולכתחלה צריך שיטעמו כולם. ונראה דהלכה כשמואל דאמר אין קידוש אלא במקום סעודה. ואע"ג דבעלמא הלכה כרב באיסורי - וגם ר' יוחנן סבר לקמן כרב - הכא הלכה כשמואל, דרב הונא ורבה ואביי כולהו סברי בסמוך אין קידוש אלא במקום סעודה. וכן פסק במגילת סתרים. והמקדש שדעתו לאכול במקום אחר יכול להוציא את האוכלים שם דלדידהו הוי מקום סעודה וכן משמע דמסתמא אחד מבני העיר היה מקדש בבהכ"נ ומוציא האורחים והיכא דליכא אורחים סמוך לבהכ"נ אין לקדש דהויא ברכה לבטלה...

כתב בשם רב נטרונאי גאון בתשובות מקדשין בבית הכנסת ונותן לתוך עיניו לרפואה כדאמר (ברכות ד' מג:) פסיעה גסה נוטלת אחד מת"ק מאור עיניו ואימת מהדרא ליה בקידושא דבי שימשי ומיהו באבי העזרי כתוב דהאי רפואה מצי למיעבד בקידוש שבביתו:

אין קידוש אלא במקום סעודה והמקדש לאחרים בביתם הם יוצאים. כשאין אורחים בבית הכנסת אין לקדש.

ונוהגין בכל המקומות שש"ץ מקדש בבה"כ ואני תמה היאך נתפשט זה המנהג דהא קי"ל כשמואל שאין קידוש אלא במקום סעודה ולדידיה אין מקדשין בבה"כ אלא לאפוקי אורחין דאכלי ושתי בבי כנישתא דלדידהו הוי מקום סעודה וכיון דהשתא ליכא אורחין דאכלי התם קרוב הדבר להיות ברכה לבטלה... וכיון דליכא אורחין ראוי היה שלא לקדש ואי איישר חילי אבטליניה וכ"כ רב האי שאם אין אורחין אין מקדשין בבהכ"נ:

It is the minhag in all places that the shaliach tzibur makes kiddush in the Beit Knesset. And I wonder how this minhag became because it was accepted by us to follow Shmuel [and hold that kiddush only works bmakom seuda]. And as for me the only reason I see to make kiddush in shul is for guests that are eating and drinking in the Beit Knesset because for them it is their makom seuda. And since now there aren't guest eating in shul making kiddush Friday night in the Beit Knesset would practically be a bracha lvatala: And the person making kiddush in shul shouldn't drink from the kiddush wine because if they’re making it in a place thats not makom seuda it is prohibited for them to eat anything until they make kiddush bmakom seuda, instead they should give it to a child to drink which we know works because Psachim 106a says the one making kiddush must drink the wine, this doesn't mean the one making kiddush has to drink, rather someone else also can.

...וה"ר יונה פי' דאינה ברכה לבטלה דהא דאמרינן דאין קידוש אלא במקום סעודה היינו מדרבנן ואסמכוה רבנן אקרא וקראת לשבת עונג ועיקר הקידוש מן התורה הוא הילכך כיון שיש בני אדם שאין יודעין לקדש נהגו לקדש בב"ה כדי שיצאו ידי קידוש מן התורה והא דקאמר אין קידוש אלא במקום סעודה לא משמע כפירושו דמשמע שאינו קידוש כלל...

If you have time, read this section by the Ran - what reason does he give for the practice?

לאפוקי אורחים ידי חובתן דאכלו ושתו בבי כנישתא. שאע"פ שאמרו (מגילה כח.) בבתי כנסיות שאין אוכלין בהן ואין שותין בהן אפשר דאורחין מותרין שמצות הרבים היא שאוכלין שם מקופה של צדקה של בני העיר. אי נמי דאכלי בבי כנשתא לאו דוקא אלא בחדרים הסמוכים לה ושומעין קדוש משם שהוא קביעות סעודתן ואנו עכשיו אף על גב דלא אכלי אורחין בבי כנשתא ונקטינן דאין קדוש אלא במקום סעודה אפילו הכי נקטינן לקדושי בבי כנישתא. דכיון דמעיקרא אתקון משום אורחים אמרינן ליה שתקנות חכמים קבועות הן. כדאשכחינן במעין שבע דמערב שבת (דף כד:) דאתקון משום עם שבשדות הבאים באחרונה, ואפילו היכא דליתא לההיא טעמא כגון דאיתנהו כולהו בבי כנשתא אמרינן ליה דכיון דאתקן אתקן:

Shulchan Aruch OH 269:1, and continue to the next page to finish the paragraph. If you have time, read the first comment of Magen Avraham.

(א) דין הקידוש בבהכ"נ. ובו סעיף אחד:
נוהגין לקדש בבהכ"נ. ואין למקדש לטעום מיין הקידוש אלא מטעימו לקטן דאין קידוש אלא במקום סעודה (וע"ל סי' רע"ג) ומעיקרא לא נתקן אלא בשביל אורחים דאכלי ושתי בבי כנישתא להוציאם י"ח ועכשיו אע"ג דלא אכלי אורחים בבי כנישתא לא בטלה התקנה זהו טעם המקומו' שנהגו לקדש בבהכ"נ אבל יותר טוב להנהיג שלא לקדש בבהכ"נ וכן מנהג א"י: הגה ונהגו לעמוד בשעה שמקדשין בבהכ"נ:

(1) It is the custom to recite Kiddush in the synagogue. The one who recites should not taste the wine of Kiddush but gives it to a minor to taste because Kiddush should be recited only at the place where the meal is eaten. From the outset this was ordained only for the sake of [communal] guests who eat and drink in the synagogue, so that they may fulfill their obligation. And today, even though [communal] guests do not eat and drink in the synagogue, the ordinance is not void. That is the reason of those places who still recite Kiddush in the synagogue. But it is better to ordain NOT to recite Kiddush in the synagogue, and such is the custom in the Land of Israel.

(2) Gloss by Rema: It is the custom to stand when reciting Kiddush in the synagogue