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-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.
- Create a
.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
indrc/server.js
file -
Add
NEWSLETTER_API_TOKEN
in session by usingsapper.middleware
-
You can check how you can access
NEWSLETTER_API_TOKEN
inpreload
function ofsrc/routes/index.svelte
page component -
You can check how you can access
NEWSLETTER_API_TOKEN
throughsession
store across every component insrc/components/Nav.svelte
component