This is a casual photo search app built in Svelte. It shows how to use:
Svelte's lifecycle hooks
Transitions for visual polish
API integration with a reactive interface
Reactive input for search queries
Unsplash API integration
Animated photo transitions (fly and fade)
Svelte lifecycle logging (onMount, onDestroy, etc.)
Clean layout with simple responsive styling
Lifecycle Hooks:
onMount, onDestroy, beforeUpdate, afterUpdate from Svelte
Transitions:
fade, fly from svelte/transition
Variables:
search_term: stores user input
photos: stores API response (photo list)
onMount: Fires once on component load → fetches default photos
onDestroy: Fires when the component is destroyed → logs a message
beforeUpdate: Fires before any DOM update → logs a message
afterUpdate: Fires after the DOM updates → logs a message
fetchData():
Fetches from Unsplash using search_term (or defaults to "animals")
Updates the photos array with the results
handleFetch():
Triggered by button click
Calls fetchData() using the current search term
Clears the search input after fetching
A search bar and button for user input
Image results rendered using {#each}
Each image:
Slides in (fly) with a staggered delay
Fades out (fade) on removal
Simple layout using flexbox
Responsive grid for images
Styled search input and fetch button
Imported a custom Header component
Wrapped layout with a global app structure (main footer )
Footer includes a link to SvelteKit docs