ππ» myapp58 μ nextjsμλ² μ€νμ(nextjs16) λ°μνλ tailwind μ€λ₯μ μ‘ν°λΈ ν
λ§ λλ ν 리λ νμΌμ΄λ¦ λ³κ²½μ μλ¬λ‘κ·Έ λ°μ λΆλΆμ λ²κ·Έλ₯Ό μμ ν©λλ€.
myapp58 fixes bugs related to Tailwind errors occurring when running the Next.js server(Nextjs16) and error logs generated when changing the active theme directory or file names.
ππ» μ 체 μ½λλ κΉνλΈμμ νμΈ ν μ μμ΅λλ€.
You can find the full code on GitHub.
https://github.com/gideonslife01/flm-nextjs
π μ 체 νλ‘μ νΈ κ΅¬μ‘° / Overall Project Structure
myapp project/
βββ app/ (Next.js App Router)
β βββ .well-known/webfinger/route.ts -> webfinger
β βββ api/follow/route.ts -> Follow API(temporary)
β βββ api/announce/route.ts -> Boost(Announcement)
β βββ api/like/route.ts. -> Like API
β βββ api/posts/route.ts -> Writing API(deprecated)
β βββ api/timeline/route.ts -> Timeline API
β βββ api/followinglist/route.ts -> followinglist API
β βββ api/followerslist/route.ts -> followerslist API
β βββ api/v1/instance/route.ts -> auth
β βββ api/v1/apps/route.ts. -> auth
β βββ api/v1/accounts/verify_credentials/route.ts -> auth
β βββ api/v1/statuses/route.ts -> Write Post
β βββ api/v1/timelines/home/route.ts -> timeline
β βββ api/v1/media/route.ts -> Image upload
β βββ api/v1/media/[id]/route.ts -> Image Delete
β βββ api/v1/instance/rules/route.ts -> Feature not implemented.
β βββ api/v1/instance/domain_blocks/route.ts -> Feature not implemented.
β βββ api/v1/filters/route.ts -> Feature not implemented.
β βββ api/v1/lists/route.ts -> Feature not implemented.
β βββ api/v1/announcements/route.ts -> Feature not implemented.
β βββ api/v1/timelines/public/route.ts -> Feature not implemented.
β βββ api/v1/statuses/[id]/context/route.ts -> Post Check,Delete
β βββ oauth/authorize/route.ts -> auth
β βββ oauth/token/route.ts -> auth
β βββ oauth/login-and-authorize/route.ts -> Tursky,Pinafore login processing
β βββ oauth/revoke/route.ts -> Feature not implemented.
β βββ api/v1/search/home/route.ts -> search
β βββ api/v2/search/home/route.ts -> search
β βββ api/v2/notifications/policy/route.ts-> Feature not implemented.
β βββ api/v1/accounts/[id]/followers/route.ts -> followers
β βββ api/v1/accounts/[id]/following/route.ts -> following
β βββ api/v1/statuses/[id]/route.ts -> -> Post delete(pinafore)
β βββ api/auth/signup/route.ts -> Website Signup
β βββ api/auth/login/route.ts -> Website Login
β βββ api/auth/logout/route.ts -> Website Logout
β βββ api/auth/refresh/route.ts -> Refresh Token
β βββ api/cleanup-orphan/route.ts -> post,outbox clean up
β βββ api/auth/me/route.tsx -> Login Check
β βββ auth/signup/page.tsx -> Signup UI
β βββ auth/signup/page.tsx -> Login UI
β βββ users/[username]/
β β βββ statuses/[id]/route.ts -> Indivisual Post
β β βββ route.ts -> Acotr Information
β β βββ followers/route.ts -> Followers List
β β βββ following/route.ts -> Following List
β β βββ inbox/route.ts -> Inbox
β β βββ outbox/route.ts -> outbox
β βββ usersui/[username]/
β β βββ page.tsx -> Timeline UI(Server, 404)
β β βββ ClientPage.tsx. -> Timeline UI(Client,Call Active Themes)
β β βββ _components/themes/
β β βββ themeex/ThemeexTheme.tsx -> Example Theme
β β βββ pinafore/PinaforeTheme.tsx -> Theme 1
β β βββ pinafore/FollowersList.tsx -> Theme 1, FollowersList
β β βββ pinafore/FollowingList.tsx -> Theme 1, FollowingList
β β βββ pinafore/NotificationsList.tsx -> Theme 1, NotificationsList
β β βββ pinafore/TimelineList.tsx -> Theme 1, TimelineList
β β βββ mastodon/MastodonTheme.tsx -> Theme 2
β β βββ minimal/MinimaltTheme.tsx -> Theme 3
β βββ layout.tsx, page.tsx, globals.css
β βββ favicon.ico
βββ lib/
β βββ theme.tsx -> Theme Provider
β βββ watchThemes.ts -> Check real-time theme changes
β βββ auth.ts -> Authentication, User Management
β βββ ap.ts -> Follow,Undo,Create,Likes,Announce
β βββ visibility.ts -> Visibility(Public,Unlisted,Private,Direct)
β βββ db.ts -> DB connection
βββ data/
β βββ keys/userIDs/ -> private.pem, public.pem(New)
β βββ keys/ -> private.pem, public.pem(legacy)
βββ data.sqlite -> Database(1/3)
βββ data.sqlite-wal -> Database(2/3)
βββ data.sqlite-shm -> Database(3/3)
βββ Caddyfile -> https
βββ instrumentation.ts -> Background Server
βββ proxy.ts -> middleware.ts - >proxy.ts(for Nextjs16)
βββ postcss.config.mjs -> for Nextjs16
βββ package.json
π νλ‘μ νΈ μμ / Project Start
π Nextj16 middleware.ts -> proxy.ts
βοΈ μλμ κ°μ κ²½κ³ λ¬Έκ΅¬κ° λμ€λ©΄ κΈ°μ‘΄μ middleware.tsνμΌμ proxy.tsνμΌλ‘ μ΄λ¦μ λ°κΏλλ€.
If a warning message like the one below appears, rename the existing middleware.ts file to proxy.ts.
— next.js16 middleware κ²½κ³ / Next.js 16 middleware warning
β² Next.js 16.4.0 (Turbopack)
- Local: http://localhost:3000
- Network: http://192.168.0.10:3000
- Environments: .env.local
β Ready in 172ms
β Running next.config.ts took 14ms
β οΈ The "middleware" file convention is deprecated. Please use "proxy" instead.
To migrate automatically, run:
npx @next/codemod@canary middleware-to-proxy .
Learn more: https://nextjs.org/docs/messages/middleware-to-proxy
β
themes: [ 'mastodon', 'minimal', 'pinafore', 'themeex' ]
π Theme watcher started in background
— μ½λ μμ / Code Modification
# middleware.tsνμΌμ proxy.tsλ‘ μ΄λ¦μ λ°κΎΈκ³ μ½λλ₯Ό μλμ²λΌ μμ
# Rename the `middleware.ts` file to `proxy.ts` and modify the code as shown below.
//export function middleware(req: NextRequest) {
// β
myapp58
export default function proxy(req: NextRequest) { ... ...}
π Tailwind error
βοΈ μλμ κ°μ μ€λ₯ λ°μμ νλ‘μ νΈ λ£¨νΈμ postcss.config.mjs νμΌμ λ§λ€κ³ μ½λλ₯Ό μ
λ ₯ν©λλ€.
If an error like the one below occurs, create a postcss.config.mjs file in the project root and enter the code.
— Error
Unknown at rule: @theme
Generated code of PostCSS transform of file content of app/globals.css:
./app/globals.css:8:7
6 | }
7 |
> 8 | @theme inline {
| ^
9 | --color-background: var(--background);
10 | --color-foreground: var(--foreground);
11 | --font-sans: var(--font-geist-sans);
Import trace:
Client Component Browser:
./app/globals.css [Client Component Browser]
./app/layout.tsx [Server Component]
— μ½λ / Code
# postcss.config.mjs
const config = {
plugins: {
"@tailwindcss/postcss": {},
},
};
export default config;
— λͺ¨λ μ€μΉ / module install
npm install -D @tailwindcss/postcss
# or
npm install -D tailwindcss @tailwindcss/postcss
βοΈ κ³΅μ λ¬Έμ / Official Documentation (Tailwindcss for nextjs)
https://tailwindcss.com/docs/installation/framework-guides/nextjs
https://www.npmjs.com/package/@tailwindcss/postcss
π ν
λ§ λλ ν 리λ νμΌμ΄λ¦ λ³κ²½μ μλ²λ‘κ·Έμ μλ¬ λ‘κ·Έ μΆλ ₯ μ€λ₯ μμ
Fixed an issue where error logs were generated in the server logs when renaming theme directories or filenames.
βοΈ μ€λ₯ / Error
β¨― ./app/usersui/[username]/_components/themes/index.ts:4:1
Error: Module not found: Can't resolve './themeex/PinaforeTheme'
βοΈ lib/watchThemes.ts
for (const folderName of folders) {
const folderPath = path.join(themesDir, folderName);
try {
... ...
// β
myapp58
// - pinaforeλ _Fallback
if (folderName === 'pinafore') {
registryLines += ` pinafore: { component: _Fallback, label: 'pinafore' },\n`;
} else {
// β
μ μ import μν¨, requireλ₯Ό try/catch + evalλ‘ κ°μΈμ λ²λ€λ¬κ° νμΌ μμ΄λ μλ¬ μ λ΄κ²
registryLines += ` ${folderName}: { component: _load('./${folderName}/${fileBase}', '${exported}'), label: '${folderName}' },\n`;
}
} catch { continue; } // ν΄λ μ½κΈ° μ€ν¨νλ©΄ μ€ν΅ / Skip if folder reading fails
}
// β
myapp58 - write code to index.ts themeName.ts files
// λλ ν 리λ νμΌ μΈμ λͺ»νλ©΄ Pinaforeν
λ§λ‘ λ체 / If directories or files are not recognized, replace with the Pinafore theme.
const indexContent = `import { PinaforeTheme as _Fallback } from './pinafore/PinaforeTheme';
function _load(path: string, exportName: string) {
try {
const mod = eval('require')(path);
return mod[exportName] || mod.default || _Fallback;
} catch {
return _Fallback;
}
}
export const themeRegistry = {
${registryLines}} as const;
export type ThemeName = keyof typeof themeRegistry;
export function getThemeComponent(name: ThemeName) {
return themeRegistry[name]?.component?? _Fallback;
}
`;
const namesContent = `export const themeNames = ${JSON.stringify(validFolders)} as const;
export type ThemeName = typeof themeNames[number];
`;
βοΈ app/usersui/[username]/_components/themes/index.ts – μλμμ± νμΌ / Automatically generated file
— index.tsνμΌμ μλμ κ°μ νμμΌλ‘μμ± λ©λλ€.
The index.ts file is generated in the following format.
import { PinaforeTheme as _Fallback } from './pinafore/PinaforeTheme';
function _load(path: string, exportName: string) {
try {
const mod = eval('require')(path);
return mod[exportName] || mod.default || _Fallback;
} catch {
return _Fallback;
}
}
export const themeRegistry = {
mastodon: { component: _load('./mastodon/MastodonTheme', 'MastodonTheme'), label: 'mastodon' },
minimal: { component: _load('./minimal/MinimalTheme', 'MinimalTheme'), label: 'minimal' },
pinafore: { component: _Fallback, label: 'pinafore' },
themeex: { component: _load('./themeex/Themetheme', 'Theme'), label: 'themeex' },
} as const;
export type ThemeName = keyof typeof themeRegistry;
export function getThemeComponent(name: ThemeName) {
return themeRegistry[name]?.component?? _Fallback;
}
π ν μ€νΈ / Test
βοΈ Tailwind
— μλ²μμμ μ€λ₯κ° λ°μνμ§ μμ΅λλ€.
No errors occur when starting the server.

βοΈ μν°λΈ ν λ§ / Active Theme
— ν
λ§ λλ ν 리λ νμΌμ΄ μΆκ° μμ λ³κ²½μ μλ² μ€λ₯ λ‘κ·Έκ° λ°μνμ§ μμ΅λλ€.
No server error logs are generated when theme directories or files are added, deleted, or modified.

— ν λ§ λ¦¬μ€νΈ λ³κ²½ νμΈ / Check theme list changes

λ§ν볡μ 21μ₯ 22μ / Matthew 21: 22
“λν¬κ° κΈ°λν λμ 무μμ΄λ μ§ λ―Ώκ³ κ΅¬νλ κ²μ λ€ λ°μΌλ¦¬λΌ νμλλΌ”
“And everything you ask in prayer, believing, you will receive.”