https://github.com/thomasbuilds/start-oauth
Most efficient OAuth for SolidStart
https://github.com/thomasbuilds/start-oauth
npm-package oauth2 solid-js solid-start
Last synced: 10 months ago
JSON representation
Most efficient OAuth for SolidStart
- Host: GitHub
- URL: https://github.com/thomasbuilds/start-oauth
- Owner: thomasbuilds
- License: mit
- Created: 2024-05-04T10:13:19.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-07T18:17:26.000Z (over 1 year ago)
- Last Synced: 2025-03-02T10:04:29.305Z (10 months ago)
- Topics: npm-package, oauth2, solid-js, solid-start
- Language: TypeScript
- Homepage: https://npmjs.com/package/start-oauth
- Size: 8.79 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OAuth2 for SolidStart
[](https://www.npmjs.com/package/start-oauth)
This package returns the `name`, `email` and `image` of user authenticated through third party services (supporting Discord, GitHub, Google and Spotify as of now).
## Installation
```bash
# npm
npm install start-oauth
# pnpm
pnpm add start-oauth
```
## Configuration
```ts
//MUST BE api/oauth/[...oauth].ts
import OAuth, { type Configuration } from "start-oauth";
const configuration: Configuration = {
google: {
id: process.env.GOOGLE_ID as string,
secret: process.env.GOOGLE_SECRET as string,
state: process.env.STATE, //optional XSRF protection
},
async handler(user, redirect) {
//create user session
},
};
export const GET = OAuth(configuration);
```
- In case of error, you are redirected to page requesting login and `error` parameter specifies reason.
- Adding a `redirect` search parameter on page requesting login gives you access to the value on handler function.
```tsx
//login.tsx for example
export default function Login() {
const requestLogin = useOAuthLogin();
return (
);
}
```
The package doesn’t provide the session management.
This gives you complete control over redirections and you can seamlessly integrate multiple authentication methods sharing the same logic.
## Contributions
Please open issues for bugs and we much appreciate contributions for more provider support.