Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@auth/remix framework for using @auth in remix #6767

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3b544de
remix auth framework
coreyEntropy Jan 3, 2023
3863f69
Merge branch 'nextauthjs:main' into main
acoreyj Jan 3, 2023
7da71a5
Update packages/frameworks-remix/package.json
acoreyj Jan 4, 2023
cedcd7c
Merge branch 'nextauthjs:main' into main
acoreyj Jan 4, 2023
a9d48c6
Merge branch 'nextauthjs:main' into main
acoreyj Jan 10, 2023
4c07976
Merge branch 'nextauthjs:main' into main
acoreyj Jan 16, 2023
41520e3
updates
coreyEntropy Jan 16, 2023
1560af8
Merge branch 'main' of github.com:acoreyj/next-auth
coreyEntropy Jan 16, 2023
3a95d3a
updates
coreyEntropy Jan 16, 2023
fbbbfe3
wip
coreyEntropy Jan 16, 2023
1baf515
need tests next
acoreyj Jan 16, 2023
eac03f1
Merge branch 'nextauthjs:main' into main
acoreyj Jan 17, 2023
9219962
updates
coreyEntropy Jan 17, 2023
57a4d26
Merge branch 'main' of github.com:acoreyj/next-auth
coreyEntropy Jan 17, 2023
8aa88a6
params refractor
acoreyj Jan 17, 2023
c44a420
Merge branch 'main' of github.com:acoreyj/next-auth
acoreyj Jan 17, 2023
e4a106a
Waiting for remix bug fixes
coreyEntropy Jan 17, 2023
30fe74e
remove unecessary
coreyEntropy Jan 17, 2023
ee2f6ef
remix note
coreyEntropy Jan 17, 2023
09a3864
Merge branch 'main' into main
acoreyj Jan 18, 2023
04776fb
fix email creating bad url
coreyEntropy Jan 24, 2023
999b161
Merge branch 'main' of github.com:acoreyj/next-auth
coreyEntropy Jan 24, 2023
8293aae
Merge branch 'main' of github.com:acoreyj/next-auth
coreyEntropy Jan 24, 2023
115d7e5
fixes
coreyEntropy Jan 25, 2023
4d55fd9
updates
coreyEntropy Feb 18, 2023
23d9dbe
updates
coreyEntropy Feb 20, 2023
53ae974
Merge branch 'main' into remix-auth
coreyEntropy Feb 20, 2023
f9ec39f
Merge branch 'main' into remix-auth
acoreyj Sep 9, 2024
5008e6b
update remix version
acoreyj Sep 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
params refractor
  • Loading branch information
acoreyj committed Jan 17, 2023
commit 8aa88a6b47a82d3bf21d79de0911d1e81b43a105
4 changes: 4 additions & 0 deletions apps/examples/remix/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: ["@remix-run/eslint-config", "@remix-run/eslint-config/node"],
};
6 changes: 6 additions & 0 deletions apps/examples/remix/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules

/.cache
/build
/public/build
.env
53 changes: 53 additions & 0 deletions apps/examples/remix/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Welcome to Remix!

- [Remix Docs](https://remix.run/docs)

## Development

From your terminal:

```sh
npm run dev
```

This starts your app in development mode, rebuilding assets on file changes.

## Deployment

First, build your app for production:

```sh
npm run build
```

Then run the app in production mode:

```sh
npm start
```

Now you'll need to pick a host to deploy it to.

### DIY

If you're familiar with deploying node applications, the built-in Remix app server is production-ready.

Make sure to deploy the output of `remix build`

- `build/`
- `public/build/`

### Using a Template

When you ran `npx create-remix@latest` there were a few choices for hosting. You can run that again to create a new project, then copy over your `app/` folder to the new project that's pre-configured for your target server.

```sh
cd ..
# create a new project, and pick a pre-configured host
npx create-remix@latest
cd my-new-remix-app
# remove the new project's app (not the old one!)
rm -rf app
# copy your app over
cp -R ../my-old-remix-app/app app
```
22 changes: 22 additions & 0 deletions apps/examples/remix/app/entry.client.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { RemixBrowser } from "@remix-run/react";
import { startTransition, StrictMode } from "react";
import { hydrateRoot } from "react-dom/client";

function hydrate() {
startTransition(() => {
hydrateRoot(
document,
<StrictMode>
<RemixBrowser />
</StrictMode>
);
});
}

if (typeof requestIdleCallback === "function") {
requestIdleCallback(hydrate);
} else {
// Safari doesn't support requestIdleCallback
// https://caniuse.com/requestidlecallback
setTimeout(hydrate, 1);
}
111 changes: 111 additions & 0 deletions apps/examples/remix/app/entry.server.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import { PassThrough } from "stream";
import type { EntryContext } from "@remix-run/node";
import { Response } from "@remix-run/node";
import { RemixServer } from "@remix-run/react";
import isbot from "isbot";
import { renderToPipeableStream } from "react-dom/server";

const ABORT_DELAY = 5000;

export default function handleRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext
) {
return isbot(request.headers.get("user-agent"))
? handleBotRequest(
request,
responseStatusCode,
responseHeaders,
remixContext
)
: handleBrowserRequest(
request,
responseStatusCode,
responseHeaders,
remixContext
);
}

function handleBotRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext
) {
return new Promise((resolve, reject) => {
let didError = false;

const { pipe, abort } = renderToPipeableStream(
<RemixServer context={remixContext} url={request.url} />,
{
onAllReady() {
const body = new PassThrough();

responseHeaders.set("Content-Type", "text/html");

resolve(
new Response(body, {
headers: responseHeaders,
status: didError ? 500 : responseStatusCode,
})
);

pipe(body);
},
onShellError(error: unknown) {
reject(error);
},
onError(error: unknown) {
didError = true;

console.error(error);
},
}
);

setTimeout(abort, ABORT_DELAY);
});
}

function handleBrowserRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext
) {
return new Promise((resolve, reject) => {
let didError = false;

const { pipe, abort } = renderToPipeableStream(
<RemixServer context={remixContext} url={request.url} />,
{
onShellReady() {
const body = new PassThrough();

responseHeaders.set("Content-Type", "text/html");

resolve(
new Response(body, {
headers: responseHeaders,
status: didError ? 500 : responseStatusCode,
})
);

pipe(body);
},
onShellError(err: unknown) {
reject(err);
},
onError(error: unknown) {
didError = true;

console.error(error);
},
}
);

setTimeout(abort, ABORT_DELAY);
});
}
32 changes: 32 additions & 0 deletions apps/examples/remix/app/root.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { MetaFunction } from "@remix-run/node";
import {
Links,
LiveReload,
Meta,
Outlet,
Scripts,
ScrollRestoration,
} from "@remix-run/react";

export const meta: MetaFunction = () => ({
charset: "utf-8",
title: "New Remix App",
viewport: "width=device-width,initial-scale=1",
});

export default function App() {
return (
<html lang="en">
<head>
<Meta />
<Links />
</head>
<body>
<Outlet />
<ScrollRestoration />
<Scripts />
<LiveReload />
</body>
</html>
);
}
32 changes: 32 additions & 0 deletions apps/examples/remix/app/routes/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export default function Index() {
return (
<div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.4" }}>
<h1>Welcome to Remix</h1>
<ul>
<li>
<a
target="_blank"
href="https://remix.run/tutorials/blog"
rel="noreferrer"
>
15m Quickstart Blog Tutorial
</a>
</li>
<li>
<a
target="_blank"
href="https://remix.run/tutorials/jokes"
rel="noreferrer"
>
Deep Dive Jokes App Tutorial
</a>
</li>
<li>
<a target="_blank" href="https://remix.run/docs" rel="noreferrer">
Remix Docs
</a>
</li>
</ul>
</div>
);
}
29 changes: 29 additions & 0 deletions apps/examples/remix/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"private": true,
"sideEffects": false,
"scripts": {
"build": "remix build",
"dev": "remix dev",
"start": "remix-serve build",
"typecheck": "tsc -b"
},
"dependencies": {
"@remix-run/node": "^1.10.1",
"@remix-run/react": "^1.10.1",
"@remix-run/serve": "^1.10.1",
"isbot": "^3.6.5",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@remix-run/dev": "^1.10.1",
"@remix-run/eslint-config": "^1.10.1",
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.8",
"eslint": "^8.27.0",
"typescript": "^4.8.4"
},
"engines": {
"node": ">=14"
}
}
Binary file added apps/examples/remix/public/favicon.ico
Binary file not shown.
8 changes: 8 additions & 0 deletions apps/examples/remix/remix.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('@remix-run/dev').AppConfig} */
module.exports = {
ignoredRouteFiles: ["**/.*"],
// appDirectory: "app",
// assetsBuildDirectory: "public/build",
// serverBuildPath: "build/index.js",
// publicPath: "/build/",
};
2 changes: 2 additions & 0 deletions apps/examples/remix/remix.env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// <reference types="@remix-run/dev" />
/// <reference types="@remix-run/node" />
22 changes: 22 additions & 0 deletions apps/examples/remix/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2019"],
"isolatedModules": true,
"esModuleInterop": true,
"jsx": "react-jsx",
"moduleResolution": "node",
"resolveJsonModule": true,
"target": "ES2019",
"strict": true,
"allowJs": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"paths": {
"~/*": ["./app/*"]
},

// Remix takes care of building everything in `remix build`.
"noEmit": true
}
}
Loading