Skip to content

Full Toolkit for Next-Level Domain Analysis

Migrate landing page to app dir 🚛

Felix Wotschofsky08a45109a862
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..d067910
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,4 @@
+{
+ "typescript.tsdk": "node_modules/typescript/lib",
+ "typescript.enablePromptUseWorkspaceTsdk": true
+}
\ No newline at end of file
diff --git a/app/head.tsx b/app/head.tsx
new file mode 100644
index 0000000..ef9f57e
--- /dev/null
+++ b/app/head.tsx
@@ -0,0 +1,9 @@
+const Head = () => (
+ <>
+ <title></title>
+ <meta content="width=device-width, initial-scale=1" name="viewport" />
+ <link rel="icon" href="/favicon.ico" />
+ </>
+);
+
+export default Head;
diff --git a/app/layout.tsx b/app/layout.tsx
new file mode 100644
index 0000000..1f06ee8
--- /dev/null
+++ b/app/layout.tsx
@@ -0,0 +1,45 @@
+'use client';
+
+import Footer from '@/components/Footer';
+import Header from '@/components/Header';
+import {
+ chakra,
+ ChakraProvider,
+ ColorModeScript,
+ Flex,
+} from '@chakra-ui/react';
+import type { ReactNode } from 'react';
+import { SWRConfig } from 'swr';
+
+const RootLayout = ({ children }: { children: ReactNode }) => {
+ return (
+ <html>
+ <head />
+ <body>
+ <ColorModeScript initialColorMode="system" />
+ <SWRConfig
+ value={{ fetcher: (url) => fetch(url).then((res) => res.json()) }}
+ >
+ <ChakraProvider>
+ <Flex
+ minH="100vh"
+ direction="column"
+ align="center"
+ justify="center"
+ >
+ <Header />
+
+ <chakra.div width="100%" flex={1}>
+ {children}
+ </chakra.div>
+
+ <Footer />
+ </Flex>
+ </ChakraProvider>
+ </SWRConfig>
+ </body>
+ </html>
+ );
+};
+
+export default RootLayout;
diff --git a/pages/index.tsx b/app/page.tsx
similarity index 93%
rename from pages/index.tsx
rename to app/page.tsx
index a4f7a19..3b5332c 100644
--- a/pages/index.tsx
+++ b/app/page.tsx
@@ -1,4 +1,5 @@
-import Head from 'next/head';
+'use client';
+
import { Container, Heading, Text, useColorModeValue } from '@chakra-ui/react';
import BookmarkletLink from '@/components/BookmarkletLink';
@@ -9,9 +10,7 @@ import SearchForm from '@/components/SearchForm';
const Home = () => {
return (
<>
- <Head>
- <title>Domain Digger</title>
- </Head>
+ <title>Domain Digger</title>
<Container
maxW="lg"
diff --git a/components/SearchForm.tsx b/components/SearchForm.tsx
index e2aba3d..d485076 100644
--- a/components/SearchForm.tsx
+++ b/components/SearchForm.tsx
@@ -1,7 +1,7 @@
import { ChangeEvent, FormEvent, useEffect, useState } from 'react';
import { Stack, FormControl, Input, Button, Text } from '@chakra-ui/react';
import { toASCII } from 'punycode';
-import { useRouter } from 'next/router';
+import { useRouter } from 'next/navigation';
import isValidDomain from 'is-valid-domain';
enum FormStates {
@@ -42,18 +42,6 @@ const SearchForm = (props: SearchFormProps) => {
router.push(`/lookup/${normalizedDomain}`);
};
- useEffect(() => {
- const resetForm = () => setState(FormStates.Initial);
-
- router.events.on('routeChangeComplete', resetForm);
- router.events.on('routeChangeError', resetForm);
-
- return () => {
- router.events.off('routeChangeComplete', resetForm);
- router.events.off('routeChangeError', resetForm);
- };
- }, [router]);
-
return (
<>
<Stack
diff --git a/next.config.js b/next.config.js
index 0d60710..fd4331f 100644
--- a/next.config.js
+++ b/next.config.js
@@ -1,3 +1,6 @@
module.exports = {
reactStrictMode: true,
+ experimental: {
+ appDir: true
+ }
}
diff --git a/tsconfig.json b/tsconfig.json
index 688f850..46d1b46 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -32,12 +32,18 @@
"utils/*"
]
},
- "incremental": true
+ "incremental": true,
+ "plugins": [
+ {
+ "name": "next"
+ }
+ ]
},
"include": [
"next-env.d.ts",
"**/*.ts",
- "**/*.tsx"
+ "**/*.tsx",
+ ".next/types/**/*.ts"
],
"exclude": [
"node_modules"