Skip to content

Commit

Permalink
docs(README): update docs to match Remix v2 (#484)
Browse files Browse the repository at this point in the history
  • Loading branch information
JosteinKringlen authored Nov 12, 2023
1 parent 56e1bbb commit 222980b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/orange-dolls-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'remix-auth-spotify': patch
---

Update docs
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ authenticator.use(spotifyStrategy);
### Setup authentication routes

```TSX
// app/routes/auth/spotify.tsx
import type { ActionArgs } from '@remix-run/node';
// app/routes/auth.spotify.tsx
import type { ActionFunctionArgs } from '@remix-run/node';
import { redirect } from '@remix-run/node';

import { authenticator } from '~/services/auth.server';
Expand All @@ -125,18 +125,18 @@ export function loader() {
return redirect('/login');
}

export async function action({ request }: ActionArgs) {
export async function action({ request }: ActionFunctionArgs) {
return await authenticator.authenticate('spotify', request);
}
```

```TSX
// app/routes/auth/spotify.callback.tsx
import type { LoaderArgs } from '@remix-run/node';
// app/routes/auth.spotify.callback.tsx
import type { LoaderFunctionArgs } from '@remix-run/node';

import { authenticator } from '~/services/auth.server';

export function loader({ request }: LoaderArgs) {
export function loader({ request }: LoaderFunctionArgs) {
return authenticator.authenticate('spotify', request, {
successRedirect: '/',
failureRedirect: '/login',
Expand All @@ -146,12 +146,12 @@ export function loader({ request }: LoaderArgs) {

```TSX
// app/routes/logout.tsx
import type { ActionArgs } from '@remix-run/node';
import type { ActionFunctionArgs } from '@remix-run/node';
import { json, redirect } from '@remix-run/node';

import { destroySession, getSession } from '~/services/session.server';

export async function action({ request }: ActionArgs) {
export async function action({ request }: ActionFunctionArgs) {
return redirect('/', {
headers: {
'Set-Cookie': await destroySession(
Expand All @@ -171,13 +171,13 @@ export function loader() {
> `spotifyStrategy.getSession()` works similar to `authenticator.isAuthenticated()`, only it handles refreshing tokens. If you don't need to refresh tokens in your app, feel free to use `authenticator.isAuthenticated()` instead.
```TSX
// app/routes/index.tsx
import type { LoaderArgs } from '@remix-run/node';
// app/routes/_index.tsx
import type { LoaderFunctionArgs } from '@remix-run/node';
import { Form, useLoaderData } from '@remix-run/react';

import { spotifyStrategy } from '~/services/auth.server';

export async function loader({ request }: LoaderArgs) {
export async function loader({ request }: LoaderFunctionArgs) {
return spotifyStrategy.getSession(request);
}

Expand Down

0 comments on commit 222980b

Please sign in to comment.