Supabase 如何在 5 分鐘內為以色列用戶設定電話登入
Phone sign-in for Israeli users in Supabase, in 5 minutes
Otipi 示範透過 Send SMS hook,使用本地服務發送 Supabase 登入驗證碼,讓以色列用戶毋須編寫後端即可使用電話登入。設定時需在 Supabase 加入 hook 地址及密鑰,並由 hook 驗證呼叫簽名。月費計劃每則 SMS 訊息部分由 6 agorot 起,完成一次身份驗證後亦可用商戶名稱作為發送者。
Posted on Nov 27 AI-assisted
Supabase Auth supports phone sign-in out of the box. If your users are in Israel, there are two catches: the built-in SMS providers bill in dollars per message part, and Israeli rules ask that every SMS sender is checked, which those providers leave to you.
This post shows how to send Supabase login codes through a local provider with the Send SMS hook, without writing a backend. It takes about five minutes.
What you need
- A Supabase project of your own.
- A free Otipi test key: otipi.co.il, no card. Test codes go to your own phone and email.
1. Get the hook address
In the Otipi dashboard open Connect. There is one hook address and one secret for the whole account:
URL: https://otipi.co.il/v1/integrations/supabase/sms/<token>
Secret: v1,whsec_...
2. Add the hook in Supabase
In Supabase go to Authentication → Hooks → Send SMS hook, choose the HTTPS type and paste the address and the secret.
Supabase signs every call with the Standard Webhooks signature, and the hook refuses calls without a valid one. A repeated call is handled once.
3. Sign in as usual
Your app code does not change:
const { error } = await supabase.auth.signInWithOtp({ phone: '+972501234567' })
// later, with the code the person typed
const { data } = await supabase.auth.verifyOtp({
phone: '+972501234567',
token: '482917',
type: 'sms',
})
The code arrives by SMS, and the message shows up in the Otipi log with its delivery status.
Auth emails too
Add a Send Email hook the same way. Letters for signup, magic link, password recovery and email change go from your own domain once it is verified, right-to-left in Hebrew and Arabic.
Why bother
- Prices in shekels: monthly plans from 6 agorot an SMS part, nothing charged beyond the plan.
- Your name as the sender: after a one-time identity check, codes come from your business name instead of a random number.
- Texts in four languages: Hebrew, Arabic, Russian and English.
- AI builders: there is a ready-made prompt for Lovable and Cursor, and an MCP server for Claude and ChatGPT.
Without Supabase
The same codes are two plain HTTP calls:
curl https://otipi.co.il/v1/otp/send \
-H "Authorization: Bearer $OTIPI_KEY" \
-H "Content-Type: application/json" \
-d '{"to":"+972501234567","app":"MyApp","language":"he"}'
curl https://otipi.co.il/v1/otp/verify \
-H "Authorization: Bearer $OTIPI_KEY" \
-H "Content-Type: application/json" \
-d '{"to":"+972501234567","code":"482917"}'
Full guide with the questions people ask: Supabase phone sign-in for Israel.
Disclosure: I build Otipi (otipi.co.il), an Israeli API for SMS, login codes and transactional email. Questions about Supabase phone auth for Israeli users are welcome in the comments.
來源:DEV Community · dev.to