Next.js 14 ã® Server Actions ã® stable ãªãªã¼ã¹ã«çºè¡¨ã¯å¤§ããªåé¿ãå¼ã³ã¾ããã ç¹ã« <button> ã® formAction å±æ§å ã§ç´æ¥ SQL ã¯ã¨ãªãå®è¡ããã³ã¼ãã¯å¤ãã®äººã«è¡æãä¸ãã¦ãã¾ããã"use server;" ã®é¨åã PHP ããã¤ããªã«ç½®ãæããã¨è¡ã£ãå¤ãã®ãã¼ã ãçã¾ãã¾ããã function Bookmark({ slug }) { return ( <button formAction={async () => { "use server"; await sql`INSERT INTO Bookmarks (slug) VALUES (${slug})`; }} > <BookmarkIcon> </button> ) } X ä¸ã§ã®åå¿ãè¦ãã¨ããã®ã¯ã©ã¤ã³ãããç´æ¥ SQL ã¯ã¨ãªãå®è¡ããã³ã¼ãã¯è¦ãç®ã®å°è±¡
{{#tags}}- {{label}}
{{/tags}}