The default Sapper template, available for Rollup and webpack.
degit
degit
is a scaffolding tool that lets you create a directory from a branch in a repository. Use either the rollup
or webpack
branch in sapper-template
:
# for Rollup
npx degit "sveltejs/sapper-template#rollup" my-app
# for webpack
npx degit "sveltejs/sapper-template#webpack" my-app
However you get the code, you can install dependencies and run the project in development mode with:
cd my-app
npm install # or yarn
npm run dev
Open up localhost:3000 and start clicking around.
Consult sapper.svelte.dev for help getting started.
.env
file:NEWSLETTER_API_TOKEN=XXX
Include it in .gitignore
so you don't commit it accidentally
Install dotenv
package
yarn add dotenv
Bootstrap dotenv
in drc/server.js
file
Add NEWSLETTER_API_TOKEN
in session by using sapper.middleware
You can check how you can access NEWSLETTER_API_TOKEN
in preload
function of src/routes/index.svelte
page component
You can check how you can access NEWSLETTER_API_TOKEN
through session
store across every component in src/components/Nav.svelte
component