id
:Getting Started
Install
Section titled “Install”npm i svelte-inspect-valuepnpm add svelte-inspect-valueyarn add svelte-inspect-valueComponents
Section titled “Components”Importing Inspect from svelte-inspect-value makes three components available:
Inspect- Renders in the flow of your page
- Inspects single values with the
valueprop, or child values of objects/arrays with thevaluesprop - Accepts any configuration prop
Inspect.Values- Very much like
Inspect, except any prop passed to it will be inspected - Can be configured “inline”
- Very much like
Inspect.Panel- A fixed-position version of
Inspectthat can be resized, positioned and has a few more configuration options
- A fixed-position version of
<script> import Inspect from 'svelte-inspect-value';
let value = $state({ id: undefined, firstName: 'Bob', lastName: 'Alice', email: 'bob@alice.lol', introduction: `The name is Alice.
Bob Alice.`, birthDate: new Date(), website: new URL('https://alicebob.website/?ref=abcdefg#about'), age: -42, emailVerified: true, interests: ['radio', 'tv', 'internet', 'kayaks'], });</script>
<Inspect {value} /><Inspect.Values.Expand0 {...value} /><Inspect.Panel expandLevel={0} {value} />Inspect.Panel 👉 Inspect obj
10 entries
undefined
firstName
: 3 chars
lastName
: 5 chars
email
: 13 chars
introduction
: 34 chars
birthDate
: age
: emailVerified
: interests
:[ ,, ,… ]
'radio'
'tv'
'internet'
4 items
Inspect.Values id
: firstName
: 3 chars
lastName
: 5 chars
email
: 13 chars
introduction
: 34 chars
birthDate
: age
: emailVerified
: interests
:[ ,, ,… ]
'radio'
'tv'
'internet'
4 items
Example Setup
Section titled “Example Setup”Here’s a recommended setup for developing with SvelteKit:
- Add
Inspect.Panelto the root layout. - Provide InspectOptions. Set up conditional rendering using environment variables.
- Inspect the
pageobject with the Panel. Data from load functions will always be available.
<!-- +layout.svelte --><script lang="ts"> import Inspect, {InspectOptionsProvider, type InspectOptions} from 'svelte-inspect-value' import { page } from '$app/state' import { dev } from '$app/environment'
let { children } = $props()
let inspectOptions = $state<InspectOptions>({ renderIf: dev, expandLevel: 0, // other preferences })</script>
<InspectOptionsProvider options={inspectOptions}> <Inspect.Panel values={{ // spread to access getters page: { ...page }, // or just pass page data pageData: page.data }} />
<main> {@render children()} </main></InspectOptionsProvider>