The default Sapper template, available for Rollup and webpack.
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-appHowever 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 devOpen up localhost:3000 and start clicking around.
Consult sapper.svelte.dev for help getting started.
- Create a
.envfile:
NEWSLETTER_API_TOKEN=XXX-
Include it in
.gitignoreso you don't commit it accidentally -
Install
dotenvpackage
yarn add dotenv-
Bootstrap
dotenvindrc/server.jsfile -
Add
NEWSLETTER_API_TOKENin session by usingsapper.middleware -
You can check how you can access
NEWSLETTER_API_TOKENinpreloadfunction ofsrc/routes/index.sveltepage component -
You can check how you can access
NEWSLETTER_API_TOKENthroughsessionstore across every component insrc/components/Nav.sveltecomponent