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

feat: next 15 #2000

Merged
merged 17 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/grumpy-otters-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-t3-app": minor
---

update to next.js 15
2 changes: 1 addition & 1 deletion cli/src/installers/dependencyVersionMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
export const dependencyVersionMap = {
// NextAuth.js
"next-auth": "^4.24.7",
"next-auth": "beta",
ronanru marked this conversation as resolved.
Show resolved Hide resolved
"@auth/prisma-adapter": "^1.6.0",
"@auth/drizzle-adapter": "^1.1.0",

Expand Down
17 changes: 5 additions & 12 deletions cli/src/installers/nextAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ import { type AvailableDependencies } from "~/installers/dependencyVersionMap.js
import { type Installer } from "~/installers/index.js";
import { addPackageDependency } from "~/utils/addPackageDependency.js";

export const nextAuthInstaller: Installer = ({
projectDir,
packages,
appRouter,
}) => {
export const nextAuthInstaller: Installer = ({ projectDir, packages }) => {
const usingPrisma = packages?.prisma.inUse;
const usingDrizzle = packages?.drizzle.inUse;

Expand All @@ -26,17 +22,14 @@ export const nextAuthInstaller: Installer = ({

const extrasDir = path.join(PKG_ROOT, "template/extras");

const apiHandlerFile = "src/pages/api/auth/[...nextauth].ts";
const routeHandlerFile = "src/app/api/auth/[...nextauth]/route.ts";
const srcToUse = appRouter ? routeHandlerFile : apiHandlerFile;
const apiHandlerFile = "src/app/api/auth/[...nextauth]/route.ts";

const apiHandlerSrc = path.join(extrasDir, srcToUse);
const apiHandlerDest = path.join(projectDir, srcToUse);
const apiHandlerSrc = path.join(extrasDir, apiHandlerFile);
const apiHandlerDest = path.join(projectDir, apiHandlerFile);

const authConfigSrc = path.join(
extrasDir,
"src/server",
appRouter ? "auth-app" : "auth-pages",
"src/server/auth",
usingPrisma
? "with-prisma.ts"
: usingDrizzle
Expand Down
2 changes: 1 addition & 1 deletion cli/template/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@t3-oss/env-nextjs": "^0.10.1",
"geist": "^1.3.0",
"next": "^14.2.4",
"next": "^15.0.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"zod": "^3.23.3"
Expand Down
8 changes: 2 additions & 6 deletions cli/template/extras/src/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import NextAuth from "next-auth";
import { handlers } from "~/server/auth";

import { authOptions } from "~/server/auth";

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const handler = NextAuth(authOptions);
export { handler as GET, handler as POST };
export const { GET, POST } = handlers;
4 changes: 2 additions & 2 deletions cli/template/extras/src/app/page/with-auth-trpc-tw.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Link from "next/link";

import { LatestPost } from "~/app/_components/post";
import { getServerAuthSession } from "~/server/auth";
import { auth } from "~/server/auth";
import { api, HydrateClient } from "~/trpc/server";

export default async function Home() {
const hello = await api.post.hello({ text: "from tRPC" });
const session = await getServerAuthSession();
const session = await auth();

if (session?.user) {
void api.post.getLatest.prefetch();
Expand Down
4 changes: 2 additions & 2 deletions cli/template/extras/src/app/page/with-auth-trpc.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import Link from "next/link";

import { LatestPost } from "~/app/_components/post";
import { getServerAuthSession } from "~/server/auth";
import { auth } from "~/server/auth";
import { api, HydrateClient } from "~/trpc/server";
import styles from "./index.module.css";

export default async function Home() {
const hello = await api.post.hello({ text: "from tRPC" });
const session = await getServerAuthSession();
const session = await auth();

if (session?.user) {
void api.post.getLatest.prefetch();
Expand Down
5 changes: 0 additions & 5 deletions cli/template/extras/src/pages/api/auth/[...nextauth].ts

This file was deleted.

4 changes: 2 additions & 2 deletions cli/template/extras/src/server/api/trpc-app/with-auth-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { initTRPC, TRPCError } from "@trpc/server";
import superjson from "superjson";
import { ZodError } from "zod";

import { getServerAuthSession } from "~/server/auth";
import { auth } from "~/server/auth";
import { db } from "~/server/db";

/**
Expand All @@ -27,7 +27,7 @@ import { db } from "~/server/db";
* @see https://trpc.io/docs/server/context
*/
export const createTRPCContext = async (opts: { headers: Headers }) => {
const session = await getServerAuthSession();
const session = await auth();

return {
db,
Expand Down
4 changes: 2 additions & 2 deletions cli/template/extras/src/server/api/trpc-app/with-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { initTRPC, TRPCError } from "@trpc/server";
import superjson from "superjson";
import { ZodError } from "zod";

import { getServerAuthSession } from "~/server/auth";
import { auth } from "~/server/auth";

/**
* 1. CONTEXT
Expand All @@ -25,7 +25,7 @@ import { getServerAuthSession } from "~/server/auth";
* @see https://trpc.io/docs/server/context
*/
export const createTRPCContext = async (opts: { headers: Headers }) => {
const session = await getServerAuthSession();
const session = await auth();

return {
session,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { type Session } from "next-auth";
import superjson from "superjson";
import { ZodError } from "zod";

import { getServerAuthSession } from "~/server/auth";
import { auth } from "~/server/auth";
import { db } from "~/server/db";

/**
Expand Down Expand Up @@ -55,7 +55,7 @@ export const createTRPCContext = async (opts: CreateNextContextOptions) => {
const { req, res } = opts;

// Get the session from the server using the getServerSession wrapper function
const session = await getServerAuthSession({ req, res });
const session = await auth(req, res);

return createInnerTRPCContext({
session,
Expand Down
4 changes: 2 additions & 2 deletions cli/template/extras/src/server/api/trpc-pages/with-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { type Session } from "next-auth";
import superjson from "superjson";
import { ZodError } from "zod";

import { getServerAuthSession } from "~/server/auth";
import { auth } from "~/server/auth";

/**
* 1. CONTEXT
Expand Down Expand Up @@ -53,7 +53,7 @@ export const createTRPCContext = async ({
res,
}: CreateNextContextOptions) => {
// Get the session from the server using the getServerSession wrapper function
const session = await getServerAuthSession({ req, res });
const session = await auth(req, res);

return createInnerTRPCContext({
session,
Expand Down
74 changes: 0 additions & 74 deletions cli/template/extras/src/server/auth-pages/base.ts

This file was deleted.

89 changes: 0 additions & 89 deletions cli/template/extras/src/server/auth-pages/with-drizzle.ts

This file was deleted.

Loading
Loading