Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
supabaseとSvelteKitで作るバックエンドレスなサーバーレスWebサイト / Creating with supabase and SvelteKit Backend-less serverless websites
Search
shiro seike
PRO
November 18, 2023
Programming
3
3.1k
supabaseとSvelteKitで作るバックエンドレスなサーバーレスWebサイト / Creating with supabase and SvelteKit Backend-less serverless websites
フロントエンドカンファレンス沖縄2023
https://frontend-conf.okinawa.jp
shiro seike
PRO
November 18, 2023
Tweet
Share
More Decks by shiro seike
See All by shiro seike
地方こそサーバーレス、その意義に迫るサーバーレスPHP / Serverless PHP: The Rural Areas, and Why Serverless PHP Matters
seike460
PRO
2
110
サーバーレスらしさを意識した AWSにおける開発手法 / Development methodologies in AWS that are serverless-like
seike460
PRO
1
57
OpenAPIを中心に考えるAPI開発入門 / Introduction to API Development with a Focus on OpenAPI
seike460
PRO
2
200
PHP8.3の機能を振り返る / Review of PHP 8.3 features
seike460
PRO
1
130
フルサーバーレスアーキテクチャの運用を重ねた先に見える価値 / The value that can be seen beyond the operation of a full serverless architecture
seike460
PRO
0
23
決断するための勇気、そのためのBacklog / Courage to make decisions, Backlog for that.
seike460
PRO
4
2.1k
Backlog API x Generative AI
seike460
PRO
0
90
「サーバーレス」ってなんだろう みんなでワイガヤ談義 / What is "serverless?" Wigaya discussion with everyone
seike460
PRO
0
37
とにかくHTTP3をライトニングに話す / Anyway, I'll talk to Lightning about HTTP3.
seike460
PRO
0
140
Other Decks in Programming
See All in Programming
slog登場に伴うloggerの取り回し手法の見直し / kamakura.go #6
arthur1
0
150
『WordPressコミュニティで学ぶ』OSS貢献の多様性
ippey
0
270
otelcol receiver 自作RTA / Pepabo Tech Conference #22 春のSREまつり
arthur1
0
1k
Go製Webアプリケーションのエラーとの向き合い方大全、あるいはやっぱりスタックトレース欲しいやん / Kyoto.go #50
utgwkk
6
2k
勉強会4_アップデートされたAssistantsAPIを試す
milky04
0
110
WinActorの勉強を継続する方法
tamai_63
0
130
GNU Makeの使い方 / How to use GNU Make
kaityo256
PRO
13
4.4k
Exploring Type-Informed Lint Rules in Rust based TypeScript Linters
unvalley
3
650
TypeScriptの型とパフォーマンス (TSKaigi 2024)
ypresto
14
5k
Escolhendo (ou não) o melhor ORM para o seu projeto
andreiacsilva
1
160
AmperとFleetを使ったAndroidアプリ
yoppie
0
300
ServerAction で Progressive Enhancement はどこまで頑張れるか? / progressive-enhancement-with-server-action
takefumiyoshii
6
520
Featured
See All Featured
Building Better People: How to give real-time feedback that sticks.
wjessup
356
18k
Ruby is Unlike a Banana
tanoku
96
10k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
18
7k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
9
1.3k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
660
120k
The Invisible Side of Design
smashingmag
294
49k
The Pragmatic Product Professional
lauravandoore
26
5.9k
How to train your dragon (web standard)
notwaldorf
75
5.2k
10 Git Anti Patterns You Should be Aware of
lemiorhan
649
58k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
126
32k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
245
20k
Making Projects Easy
brettharned
109
5.5k
Transcript
supabase SvelteKit Web 2023 2 0 23 . 11 .
18 @seike 4 60 1
自己 @seike 46 0 - - @seike 46 0 -
AWS Community Builder Serverless - Fusic - / 門 - / - - PHP - JAWS Days AWS Devday - Serverless Days Tokyo - - 大 工 子工 - PHP - 2
Agenda 1 .Svelte 2 .SvelteKit 3 . 4 .supabase 5
.supabase x SvelteKit 6 . 3
01 Svelte
Svelte JavaScript Svelte Svelte 言 Write less code No virtual
DOM DOM Truly reactive 自 Hooks 5
Write less code - Svelte 6 <script> let a =
1 ; let b = 2 ; </script> <input type="number" bind:value={a}> <input type="number" bind:value={b}> <p>{a} + {b} = {a + b}</p> let State bind 行 方 築 行 [a] input p [a]
Write less code + Truly reactive 7 <script> let a
= 1 ; let b = 2 ; </script> <input type="number" bind:value={a}> <input type="number" bind:value={b}> <p>{a} + {b} = {a + b}</p> Svelte ⾒
TEMPLATE SYNTAX 8 {#if porridge.temperature > 1 00 } <p>too
hot!</p> {:else if 8 0 > porridge.temperature} <p>too cold!</p> {:else} <p>just right!</p> {/if} {#each items as item} <li>{item.name} x {item.qty}</li> {/each} {#await promise} <p>waiting for the promise to resolve...</p> {:then value} <p>The value is {value}</p> {:catch error} <p>Something went wrong: {error.message}</p> {/await} {#key value} <div transition:fade>{value}</div> {/key} {#if }... {:else if } {/if} {#each as name, index} ... {/each} {#await }... {:then name}... {:catch name} … {/await} {#key }... {/key}
Props Props export 用 Props 用 生 9 Counter.svelte App.svelte
Store 10
Store writable 用 Store 用 subscribe 火 用 update set
用 Store 11
Component Hooks onMount DOM beforeUpdate state afterUpdate onDestroy 12
No virtual DOM Virtual DOM Dom 行 Virtual DOM 用
生 Svelte DOM 用 行 行 13
krausest React Vue 比 Svelte 14 https://krausest.github.io/js-framework-benchmark/current.html
02 SvelteKit
SvelteKit Svelte Vite Rollup 用 っ URL っ (SSR)
生 (SSG) 高 SEO っ っ 16
▪ϧʔςΟϯάʢRoutingʣ URLͱͦΕʹରԠ͢Δίϯςϯπͷؔ࿈͚ ▪σʔλͷಡΈࠐΈʢLoading Dataʣ ϖʔδίϯϙʔωϯτ͕ϩʔυ͞ΕΔࡍʹඞཁͳσʔλΛऔಘ ▪ϑΥʔϜΞΫγϣϯʢForm Actionsʣ ϑΥʔϜͷૹ৴࣌ʹαʔόʔଆͰߦ͏ॲཧ ▪ϖʔδΦϓγϣϯʢPage Optionsʣ
ݸʑͷϖʔδʹؔ࿈͢Δઃఆಈ࡞Λࢦఆ͢Δ ▪εςʔτཧʢState Managementʣ ΞϓϦέʔγϣϯͷঢ়ଶΛҰݩతʹཧ 17
Routing 18 src/routes/+page.svelte -> / <h 1 >Hello and welcome
to my site!</h 1 > <a href="/about">About my site</a> src/routes/about/+page.svelte -> /about <h 1 >About this site</h 1 > <p>TODO...</p> <a href= /">Home</a> src/routes/blog/[slug]/+page.svelte -> blog/hoge <script> /** @type {import('./$types').PageData} */ export let data; </script> <h 1 >{data.title}</h 1 > <div>{@html data.content}</div> SvelteKit 用 src/routes URL +error.svelte +layout.svelte API +server.js URL
Loading data 19 src/routes/blog/[slug]/+page.js /** @type {import('./$types').PageLoad} */ export function
load({ params }) { return { post: { title: `Title for ${params.slug} goes here`, content: `Content for ${params.slug} goes here` } }; } src/routes/blog/[slug]/+page.svelte <script> /** @type {import('./$types').PageData} */ export let data; </script> <h 1 >{data.post.title}</h 1 > <div>{@html data.post.content}</div> +page.svelte load +page.js load page data 用 Layout data +page.server.js cookies headers
Form actions 20 src/routes/login/+page.server.js /** @type {import('./$types').Actions} */ export const
actions = { default: async (event) => { // TODO log the user in } }; src/routes/login/+page.svelte <form method="POST"> <label> Email <input name="email" type="email"> </label> <label> Password <input name="password" type="password"> </label> <button>Log in</button> </form> +page.server.js actions <form> 用 POST 築 築 ⾒ / 築 login -> ?/login register -> ?/register
Page options 21 +page.js/+page.server.js/+server.js export const prerender = true; +page.js
export const ssr = true; っ 生 HTML 生 生 っ 生 SSR 生 示
State management 22 +page.server.js let user; /** @type {import('./$types').Actions} */
export const actions = { default: async ({ request }) => { const data = await request.formData(); // NEVER DO THIS! user = { name: data.get( ‘ name'), embarrassingSecret: data.get( ‘ secret') }; } } っ state user っload 用 っcontext store
03
- API - - API 用 - - DB 用
sqlite - - - - っ 欠 -> 身 築 or 24
非 一 一夕 身
Point BaaS
04 Supabase
supabase っPostgreSQL supabase PostgreSQL っ っ Google GitHub Facebook っ
自 API SQL RESTful API 自 PostgREST 用 っ 行 っ 一 自 行 っ GitHub 用 -> EC 2 28
Client 生 supabase Client URL KEY anonkey KEY anonkey CRUD
29 PUBLIC_SUPABASE_URL PUBLIC_SUPABASE_KEY
Anonkey Key anon Table CRUD 一方 人 人 30
Row Level Security PostgreSQL 用 row SQL 人 見
Row Level Security DB 31 supabase Row Level Security Firebase 比 @dshukertjr https://qiita.com/dshukertjr/items/ 0 5 372 4 367 fda 267 8 f 2 41
SQL 行 行 SQL Editor 用 32
SQL Editor SQL 行 行 SQL Editor 用 33
34 API from 行 select insert update delete 用 行
match like in 稿 行 order limit 用 ORM 用
Google GitHub Kakao Spotify 日 35
Storage API Amazon S 3 Storage 用 用 36
Edge Functions 用 Deno TypeScript WASM 37
金 Free 2 用 人目 $25 用 用 38
05 supabase X SvelteKit
SvelteKit supabase ⾒ SQL ⾒ Model Model 用 SQL SQL
行 手 SvelteKit supabase 自 API 生 40
UI supabase SvelteKit ⾒ UI UI subscribe
⾒ Web 41
SvelteKit 用 Vercel supabase 用 supabase SvelteKit
42
⾒ Supabase SvelteKit 用 用 Supabase
用 RowLevel RDBMS 一 43
文 っFree Free 人 用 PoC 用 用
2 ⾒ 用 ⾒ PRO 用 用 PRO っ 一方 手 自 Amazon RDS 用 44
方 https://github.com/supabase-community/svelte-kanban .env.example .env Rename 自 supabase URL anon_key SvelteKit
supabase ⾒ 方 45
Adapter svelte.config.js 用 @sveltejs/adapter-auto 自 Adapter 46
47
48
Sveltekit x Supabase x Skelton 49 SvelteKit supabase ⾒ Svelte
UI Skelton 用 ⾒ 自
方 SQL 人 力 SQL 人 GUI API 身 supabase
50
07
52 SvelteKit Point 1 supabase Point 2 SvelteKit X supabase
Point 3 SvelteKit X supabase Point 4
Thank You We are Hiring ! https://recruit.fusic.co.jp/