Overview:
The Sapper template is a default template for building web applications using the Sapper framework. It is available for both Rollup and webpack bundlers. The template provides a pre-built structure and features to help developers get started quickly with Sapper.
Features:
- Easy setup: The template can be installed using the degit scaffolding tool or by using GitHub template feature.
- Structure: The template expects a specific structure with a
srcdirectory containing entry points, astaticdirectory for static assets, and aroutesdirectory for defining pages and server routes. - Server-side rendering: Sapper enables server-side rendering of the initial route, providing a faster loading experience for users.
- Client-side routing: Once the initial route is rendered, Sapper handles client-side routing for smooth navigation between pages.
- Code-splitting and dynamic imports: Sapper uses Rollup or webpack to provide code-splitting and dynamic imports, optimizing the performance of the web application.
- Static asset management: The
staticdirectory allows developers to store and serve static assets using a built-in server. - Bundler configuration: Sapper seamlessly integrates with Rollup and webpack, allowing developers to configure code-splitting, dynamic imports, and hot module reloading (webpack only).
Installation:
To install the Sapper template, you can use either the degit tool or the GitHub template feature.
Using degit:
- Open your command line interface.
- Run the following command to create a directory from the Rollup branch of the template:
degit sveltejs/sapper-template#rollup
or run this command for the webpack branch:
degit sveltejs/sapper-template#webpack
- Change into the newly created directory:
cd sapper-template
- Install the dependencies:
npm install
- Run the project in development mode:
npm run dev
- Open your web browser and navigate to
http://localhost:3000to view the project.
Using GitHub templates:
- Go to the GitHub repositories for the
sapper-template-rolluporsapper-template-webpack. - Click on the “Use this template” button to create a new repository from the template.
- Clone the newly created repository to your local machine.
- Change into the cloned directory.
- Install the dependencies:
npm install
- Run the project in development mode:
npm run dev
- Open your web browser and navigate to
http://localhost:3000to view the project.
For further guidance on getting started with Sapper, refer to the official Sapper documentation at sapper.svelte.dev.
Summary:
The Sapper template is a convenient starting point for building web applications with the Sapper framework. It provides a pre-configured structure and features such as server-side rendering, client-side routing, code-splitting, and static asset management. By following the installation guide, developers can quickly set up the template and start developing their Sapper applications.