GithubHelp home page GithubHelp logo

aiibe / login-svelte-kit Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 214 KB

A simple login page with Firebase Auth using SvelteKit

Home Page: https://login-svelte-kit.vercel.app

JavaScript 8.05% HTML 2.84% Svelte 44.24% SCSS 12.31% TypeScript 32.55%
sveltekit typescript firebase-auth scss

login-svelte-kit's Introduction

Login with SvelteKit and Firebase (server side)

How to handle authentication with Firebase Auth in SvelteKit on server side.

It uses a sameSite httpOnly cookie to store the idToken from Firebase Auth. The token persists in $session via hooks and load function on page refresh.

Also, goto is used instead of window.location for navigate/redirect after logged in and logged out.

Note : Firebase SDKs are not used here, as I opted for Firebase REST API. Check endpoints in src/routes/auth/

Try Live Demo

email : [email protected]
password: mailmail

Developing

Once you've cloned the repo, start a development server:

npm install
npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open

Then create your own Firebase project, copy its Web API and add it in .env file like this :

VITE_FIREBASE_WEB_API="REPLACE-WITH-YOUR-WEB-API"

Don't forget to add a user in Firebase Auth console.

Building

Before creating a production version of your app, install an adapter for your target environment. Then:

npm run build

You can preview the built app with npm run preview, regardless of whether you installed an adapter. This should not be used to serve your app in production.

login-svelte-kit's People

Contributors

aiibe avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.