This project demonstrates how to implement streaming with promises in SvelteKit. It shows how to load data progressively while rendering the page, providing a better user experience compared to waiting for all data to load before rendering.
#await blocks to handle loading states and progressively update the UI./src/routes/api/ - Contains API endpoints that simulate different response times/src/routes/standard/ - Demonstrates the standard (non-streaming) approach/src/routes/streaming/ - Demonstrates streaming with promisesSvelteKit's streaming feature works by:
#await blocks in the component to handle the loading, success, and error statesYou can try this demo without any setup by visiting the CodeSandbox link below:
# Install dependencies
npm install
# Start the development server
npm run dev
Visit http://localhost:5173 to see the demo in action.
This project helps understand the practical implementation of the concepts explained in the SvelteKit documentation on streaming with promises.