dev-resources.site
for different kinds of informations.
Deep Linking for Andriod and Apple in Next.js
Published at
3/30/2024
Categories
webdev
javascript
nextjs
Author
Al-Amin Islam
Today I will discuss about how to create Android & Apple Deeplinking.
For Android
- You have
assetlinks.json
file . - Create "assetlinks.json" file. Include the file inside
public/.well-known
folder . - The route is -->
domainname/.well-known/assetlinks.json
.
For Apple
- Apple requires that your website has a file at the path
/.well-known/apple-app-site-association
on your URL. - Create an API route
- Create a file at this in your project location:
pages/api/.well-known/apple-app-site-association.ts
import type { NextApiRequest, NextApiResponse } from 'next'
const BUNDLE_ID = 'YOUR-APPLE-APP-BUNDLE-ID' // replace with your bundle ID
const association = {
applinks: {
apps: [],
details: [
{
appID: `${BUNDLE_ID}`,
paths: ['*', "/"],
},
],
},
}
export default (_: NextApiRequest, response: NextApiResponse) => {
return response.status(200).send(association)
}
Add a redirect
Finally, Apple expects this file to exist at the exact path yourdomain.com/.well-known/apple-app-site-association
.
Since the file we created above is an API route, we need to create a redirect in next.config.js:
const nextConfig = {
// ...
async redirects() {
return [
{
source: '/.well-known/:file',
destination: '/api/.well-known/:file',
permanent: false,
},
]
},
}
Test your app
First, you'll need to make sure you publish your website on the domain you used.
Thanks for reading
Articles
12 articles in total
Example of using Late Static Binding in PHP.
read article
Understanding authentication and authorization in simple words
read article
What is the process to Sign In with Apple with laravel?
read article
Why you should never use $request->all() in Laravel
read article
Answer: Error "Your push would publish a private email address"
read article
Laravel logging
read article
Displaying Unescaped Data on laravel blade file
read article
Redirecting to External Domains from Laravel
read article
Deep Linking for Android and Apple in React.js
read article
Deep Linking for Andriod and Apple in Next.js
currently reading
How to use deep linking and Apple App Site Association with React.js
read article
How to use deep linking and Apple App Site Association with React.js
read article
Featured ones: