usage README.md
This commit is contained in:
parent
a83749a2e4
commit
e180acf622
1 changed files with 32 additions and 12 deletions
40
README.md
40
README.md
|
@ -1,14 +1,16 @@
|
||||||
# Spock - Svelte + Pocketbase
|
# Spock - Svelte + Pocketbase
|
||||||
|
|
||||||
My boilerplate for
|
My boilerplate for
|
||||||
<img src="./git_assets/spock.jpg" align="center" height="64" width="48" ></a>
|
<img src="./git_assets/spock.jpg" align="center" height="64" width="48" ></a>
|
||||||
|
|
||||||
|
|
||||||
1. Sveltekit + Pocketbase DB
|
1. Sveltekit + Pocketbase DB
|
||||||
2. Tailwindcss
|
2. Tailwindcss
|
||||||
3. SkeletonUI
|
3. SkeletonUI
|
||||||
|
|
||||||
# Auth Ready
|
# Auth Ready
|
||||||
|
|
||||||
### Snippet from login.svelete component - populating name and avatar from Google provider
|
### Snippet from login.svelete component - populating name and avatar from Google provider
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { currentUser, pb } from '$lib/pocketbase';
|
import { currentUser, pb } from '$lib/pocketbase';
|
||||||
|
@ -44,22 +46,40 @@ My boilerplate for
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
### currentUser as a store to use example ``` $currentUser.avatar ```
|
### currentUser as a store to use example `$currentUser.avatar`
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { env } from '$env/dynamic/public'
|
import { env } from '$env/dynamic/public';
|
||||||
import PocketBase from 'pocketbase'
|
import PocketBase from 'pocketbase';
|
||||||
import { writable } from 'svelte/store'
|
import { writable } from 'svelte/store';
|
||||||
|
|
||||||
export const pb = new PocketBase(env.PUBLIC_DB_URL)
|
export const pb = new PocketBase(env.PUBLIC_DB_URL);
|
||||||
|
|
||||||
export const currentUser = writable(pb.authStore.model)
|
export const currentUser = writable(pb.authStore.model);
|
||||||
|
|
||||||
pb.authStore.onChange((auth) => {
|
pb.authStore.onChange((auth) => {
|
||||||
//console.log('auth changed ', auth)
|
//console.log('auth changed ', auth)
|
||||||
currentUser.set(pb.authStore.model)
|
currentUser.set(pb.authStore.model);
|
||||||
})
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
### use .env for pocketbase URL
|
### use .env for pocketbase URL
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
PUBLIC_DB_URL=http://localhost:8090
|
PUBLIC_DB_URL=http://localhost:8090
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Usage:
|
||||||
|
|
||||||
|
1. run DB in same dir
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pocketbase serve
|
||||||
|
```
|
||||||
|
|
||||||
|
2. dev mode
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bun dev OR npm run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue