
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
sveltekit-pocketbase-starter
Advanced tools
An insanely simple free plug & play setup for those wanting auth/user management in a SvelteKit app with as little pain as possible.
An insanely simple free plug & play setup for those wanting auth/user management in a SvelteKit app with as little pain as possible.
Pretty much anything you'd need can be rolled into a module under src/lib/whatever
. Then the interface can be added to app.d.ts
for type safety.
Typically anything requiring api credentials and secrets just lives on the server side (sveltekit will yell at you about importing these modules on the frontend making the secret env vars exposed). Following that, most of these examples are providers that are added to the server's event.locals
so they can be used on the server side only. If you would like to use a provider on the frontend, is possible to create an instance of one in a +page.svelte
but be sure you're not exposing anything to the client you wouldn't want the public to know.
VITE_POCKETBASE_URL=http://127.0.0.1:5555
in sveltekit-pocketbase-starter/.env.local
pocketbase
directory, Run make frontend-up
to bring up the skeleton app and navigate to /login
pocketbase
directory, Run make backend-up
to bring up PocketBasenpm run dev
npm run dev
pocketbase
directory, run docker compose up -d
to bring up pocketbase in a container.localhost:5555/_/
Set up an account if you haven't or log in, then click "Settings" (tool icon on the far left side)localhost:5173
(we need this for redirect URLs to the SvelteKit pieces later)purchaseIntent
to house the jwt containing info on what product was purchased when stripe calls us back.credits
if you intend to do a la carte type pricing (typical of generative AI type products).subscriptionID
for subscription based services.
/routes
following standard SvelteKit developer guidanceconst protectedRoutes = ['/protected']
in sveltekit-pocketbase-starter/src/routes/+layout.server.ts
/login
)/routes/buy
folder and all the stuff about nonce in routes/+layout.server.ts
.Assumes you have a SvelteKit project as created with npm create svelte@latest <project name>
npm i pocketbase
app.d.ts
to yours if you use TypeScriptHandle
logic from /hooks.server.ts
to your own /hooks.server.ts
(create this file if necessary)/routes/+layout.server.ts
load
function to your /routes/+layout.server.ts
(create this file if necessary)/routes/callback
/routes/confirm-verification
and /routes/login
folders. to your routes
. If you have a /routes/login
page, you may need to merge logic. Add styles as requiredprotectedRoutes
array in /routes/+layout.server.ts
to mark any routes you need auth blocked.Getting Started - Local Development
at least one Auth flow
👇{APP_URL}/confirm-verification/{TOKEN}
confirm-verification
folder in the sveltekit-pocketbase-starter SvelteKit project that handles flipping the "verified" flag when a user visits the Action URL from their email.http://localhost:5173/callback
callback
folder in sveltekit-pocketbase-starter SvelteKit project that handles the auth code response and requests an access token. This is why we set the "Application URL" earlierhttp://localhost:5173/login
1. You can try http://localhost:5173/protected
and see it kicks you back to /login
and /unprotected
and see the pagehttp://localhost:5173/
and navigating to /login
brings you to /
and /protected
should reveal a secret⚠️ Unless you really know what you're doing, avoid messing with hooks.server.ts
or routes/login/+page.server.ts
as that's where most of the auth magic happens
mydomain.com/_
to get into the admin panel for PocketBase and mydomain.com
for the Application name settings.main
.sk_test_
) and a pair for production (usually starting with just sk_
).env.local
(see .env-example
for a hint).env-example
)
nonce
column to the users table in pocketbase/routes/buy
to the endpoint what your offerings page is calledcredits
and in the value add a number for how many credits the product represents.urls
in /routes/buy/+page.server.ts
to reflect your prod domains and whatnot. (actually this should be env vars but I'm lazy)/routes/buy/+page.svelte
pretty. Offerings should come out from server so just decorate this page, no need for anything fancy.Sometimes you want to have users authorize your app against 3rd parties - this code contains an example for authorizing Spotify to grab some details about a user in addition to authenticating them (or signing them up if need be).
FAQs
An insanely simple free plug & play setup for those wanting auth/user management in a SvelteKit app with as little pain as possible.
We found that sveltekit-pocketbase-starter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.