服务器端渲染
How SSR works with Supabase Auth.
SSR 框架会把渲染和数据获取移到服务器端,这样可以减小客户端的包大小和执行时间。
🌐 SSR frameworks move rendering and data fetches to the server, to reduce client bundle size and execution time.
Supabase Auth 完全兼容 SSR。你需要对 Supabase 客户端的配置做一些调整,把用户会话存储在 cookie 中,而不是本地存储。设置好 Supabase 客户端后,按照操作指南中任何流程的说明进行即可。
🌐 Supabase Auth is fully compatible with SSR. You need to make a few changes to the configuration of your Supabase client, to store the user session in cookies instead of local storage. After setting up your Supabase client, follow the instructions for any flow in the How-To guides.
确保在有所不同的地方使用 PKCE 流程的说明。如果没有提到区别,就不用担心这个。
🌐 Make sure to use the PKCE flow instructions where those differ from the implicit flow instructions. If no difference is mentioned, don't worry about this.
@supabase/ssr#
我们开发了一个 @supabase/ssr 包来设置 Supabase 客户端。这个包目前处于测试阶段。建议使用,但要注意,API 仍不稳定,将来可能会有重大更改。
🌐 We have developed an @supabase/ssr package for setting up the Supabase client. This package is currently in beta. Adoption is recommended but be aware that the API is still unstable and may have breaking changes in the future.
框架快速入门 #
🌐 Framework quickstarts